Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
mangar committed Feb 11, 2013
1 parent ee83327 commit f87f044
Showing 1 changed file with 8 additions and 44 deletions.
52 changes: 8 additions & 44 deletions index.py
Expand Up @@ -3,41 +3,10 @@

from google.appengine.ext.webapp import template


BASE_CONTROLLER_DIR = "app.controllers"
EXT_ACTION = ".jhtml"

TEMPLATE_DIR = os.path.join(os.path.dirname(__file__), 'templates')


#
# Ex.:
# /admin --> from app.controllers.admin import index // chama o metodo index
# /admin/cidades --> from app.controllers.admin.cidades import index // chama o metodo index
# /admin/cidades/salvar.jhtml --> from app.controllers.admin.cidades import index // chama o metodo salvar
#
#
def import_from_statement(self):
_from = BASE_CONTROLLER_DIR
_import = "index"

url_split = self.request.path.split('/')
if not self.request.path == "/": # pacote padrao(index) e action padrao (index)
# _from = _from + "index"
# _import = "index"

# else:
for s in url_split:
if s:
if not(s.endswith(EXT_ACTION)):
_from += ("." + s)
else:
_import = s.replace(EXT_ACTION, "")

return "from " + _from + " import " + _import



from config.config import Config
from lib.gae_py.controllers.from_import_statement import FromImportStatement
from lib.gae_py.controllers.method_to_call import MethodToCall
from lib.gae_py.controllers.template_file import TemplateFile


class Handler(webapp2.RequestHandler):
Expand All @@ -52,19 +21,14 @@ def get(self):
exec "from app.controllers import %s" % "index"
exec "template_values2 = index.IndexHandler(self.request, self.response).index()"



template_values2['a'] = self.request.path
template_values2['import_from'] = import_from_statement(self)
template_values2['import_from'] = FromImportStatement(self.request).from_import_statement()
template_values2['method_to_call'] = MethodToCall(self.request).method_to_call()
template_values2['template_file'] = TemplateFile(self.request).template_file()

path = os.path.join(TEMPLATE_DIR, 'index.html')
path = os.path.join(Config.TEMPLATE_DIR, 'index.html')
self.response.out.write(template.render(path, template_values2))

# else:
# self.response.headers['Content-Type'] = 'text/plain'
# self.response.write('BE Handler %s' % path)



url_map = [ ('/.*', Handler),]

Expand Down

0 comments on commit f87f044

Please sign in to comment.