I've been playing around with modularizing my code, and so far just
one question re: self.redirect
For example, changing this:
main.py
from mainpage_get import MainPage_Get
class MainPage(webapp.RequestHandler):
def get(self):
MainPage_Get()
mainpage_get.py
def MainPage_Get():
self.redirect('/')
So the self.redirect is not going to work in any instance within
another file, is there another option? This is a simple example, my
MainPage_Get is of course very large with various checks via if/else
redirecting the user to various locations..
Wondering what others do in cases such as these.
On Dec 9, 1:10 am, G <[email protected]> wrote:
> Use templates to modularize your output, research {% extends %} {%
> block %} and {{ block.super }}. The block.super trick will enable
> DRYness.
>
> http://code.google.com/appengine/docs/python/gettingstarted/templates...http://www.djangoproject.com/documentation/0.96/templates/http://www.djangobook.com/en/1.0/chapter04/http://c2.com/cgi/wiki?DontRepeatYourself
>
> Use import to modularize your code, research 'from foo import bar as
> _baz'. The leading underscore trick will keep library namespaces
> clean (not a typical use case but when namespace polution is an issue
> a leading underscore is the solution).
>
> http://docs.python.org/tutorial/modules.htmlhttp://docs.python.org/reference/simple_stmts.html#the-import-statementhttp://wiki.python.org/moin/PythonSpeed/PerformanceTips#ImportStateme...http://stackoverflow.com/search?q=python+import
>
> --
> G
>
> On Dec 8, 11:25 pm, PatHaugen <[email protected]> wrote:
>
>
>
> > Sorry if this seems simple, but all Google searches for 'Google App
> > Engine include require PHP' or any of the variants went to websites
> > complaining about lack of PHP support in GAE.
>
> > Here is my question:
>
> > In PHP, I use include/require to break apart code into separate files
> > for simplicity and multiple developer situations. I'm at that point in
> > GAE, and was wondering if there is something I could use.
>
> > As an example, if GAE were PHP I'd do something like:
>
> > ====
>
> > main.py
> > include header.py
> > include datastore.py
> > class MainPage(webapp.RequestHandler):
> > def get(self):
> > include mainpage.py
> > def post(self):
> > include post.py
> > include footer.py
>
> > footer.py
> > application = webapp.WSGIApplication(...
> > etc..
> > def main(): run_wsgi_app(application)
> > if __name__ == "__main__": main()
>
> > header.py
> > import xxx
> > from xxx
> > etc..
>
> > datastore.py
> > class xxx(db.Model)..
> > etc..
>
> > ====
>
> > Just a quick example.
>
> > Thoughts?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.