Module: Shift::Generator::PythonTemplates

Defined in:
lib/shift-lang/generator/python_templates.rb

Constant Summary collapse

IMPORT_WEBAPP_STATEMENT =
"import webapp2"
IMPORT_PYSTACHE_STATEMENT =
"import os\nimport pystache\nmu_root = 'views/'"
IMPORT_DATABASE_STATEMENT =
"from google.appengine.ext import db"
UTILITY_FUNCTIONS =
"
def read_file(file_name):
	f = open(mu_root + file_name)
	template = f.read()
	f.close()
	return template

def read_template(file_name, template_values = None):
	template = read_file(file_name)
	if (template_values == None):
return template
	else:
return pystache.render(template, template_values)"
MODEL_NAME_TEMPLATE =
"class <%= model_name %>(db.Model):"
DB_STRING_PROPERTY =
"db.StringProperty()"
DB_INTEGER_PROPERTY =
"db.IntegerProperty()"
REQUEST_GET_VAR_TEMPLATE =
"self.request.get(<%= var_name %>)"
WRITE_FILE_TEMPLATE =
"response_result = read_template(<%= file_name %><% if template_values %>, <%= template_values %><% end %>)"
WRITE_DATA_TEMPLATE =
"response_result = <%= write_data %>"
WRITE_RESPONSE_STATEMENT =
"self.response.out.write(response_result)"
REDIRECT_STATEMENT_TEMPLATE =
"self.redirect(<%= url %>)"
WEBAPP2_APPLICATION_TEMPLATE =
"app = webapp2.WSGIApplication([<%= routes %>], debug=True)"