I was trying to do something a bit outside the box using bits and
pieces of sample code without a good understanding(shortcuts are my
nemesis).
I will recount here in case it may have use elsewhere and someone can
let me know if show a misunderstanding of best practices.

Easily muddleheaded, I was trying to find a way around large main.py
modules that did everything, imported everything and called a myriad
of request handlers and other files that I couldn't keep track of. So
what I want to do is modualize each task corresponding to its location
in the directory structure such as /patron/main.py, /patron/add/
main.py, /patron/edit/main.py.

Using /patron/edit/main.py as an example I would then place the
template, index.html, in the same directory and create a corresponding
structure for static files(/static/patron/edit/main.css.../static/
patron/edit/main.js)

In the main.py I would create a global variable:
meoPathToMe = os.environ['PATH_INFO']
which would evaluate to : /patron/edit/

and use that variable to call the handler:
application = webapp.WSGIApplication(
                                     [(meoPathToMe, MainHandler),
                                       (meoPathToMe + "meoPut",
AddPatron)
                                        ], debug=True)

I also use meoPathToMe as a template variable to grab static files:
    template_values = {
       'meoPathToMe': meoPathToMe,
      'meoPatron': meoPatron,
      }
In the index.html file:
  <link type="text/css" rel="stylesheet" href="/static{{ meoPathToMe }}
main.css" />
  <script type="text/javascript" src="/static{{ meoPathToMe }}
main.js"></script>

This allows me to use the entire structure, including handlers,
templates, css, js, as a template for a new task by copying, say /
patron/edit/ to /branch/edit/ and /static/patron/edit/ to /static/
branch/edit/ and adding to the app.yaml:

- url: /branch/edit/
  script: branch/edit/main.py

It is then a pretty simple procedure to import Branch from models.py
in place of Patron and then replace Patron.properties with
Branch.properties. If you were using Patron as a template for Author
where many of the properties would be the same, even better.

This seems more efficient to me because it is very targeted and I'm
not importing the whole farm when all I need is the outhouse. Using a
tabbed text editor, such as NoteTab, I can get a handle on the task by
having all the small files relating to it open instead of paging
through large do everything files.

I want to thank vp, jonathan, and Nick for responding. The problem
seems to have been a combination of caching of the main.py file not
allowing my variable to change for each pass and my ignorance of the
proper structure of the request. vc nailed it, replacing a / with a ?
made all the difference.

Thanks,
Michael
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to