Thanks johnwlockwood. I ended up doing this:

app.yaml:
....
- url: /.*
  script: main.py
....

main.py:
import os
import re

regex_api_site = re.compile('^api\.(localhost|mydomain\.com)$')
regex_admin_site = re.compile('^admin\.(localhost|mydomain\.com)$')

handlers_map = [
                {'regex':regex_api_site,
                 'handler':'WEBAPP'},
                {'regex':regex_admin_site,
                 'handler':'APP_ENGINE_PATCH'},
                ]

def main():
  http_host = os.environ['SERVER_NAME']
  handler = None
  for handler_info in handlers_map:
    if handler_info['regex'].match(http_host):
      if handler_info['handler'] == 'WEBAPP':
        # main_webapp.py is in the root application directory
        from main_webapp import main as handler
      elif handler_info['handler'] == 'APP_ENGINE_PATCH':
        from common.appenginepatch.main import main as handler
      break
  if not handler:
    import logging
    logging.critical('No handler found for HTTP host "%s"',http_host)
    return 1 # Not sure if this is the correct way to return "failure"
  return handler()

if __name__ == '__main__':
  main()


This seems to work well, although I haven't tried sharing models yet.


2010/1/7 johnwlockwood <johnwlockw...@gmail.com>

> you setup the app.yaml to send urls starting with /admin/ to a python
> file that loads app-engine-patch and everything else to a main.py that
> loads webapp.
> something like:
>
> - url: /admin/.*
>  script: app_engine_patch_loader.py
>  login: admin
>
> - url: /.*
>  script: main.py
>  secure: never
>
>
> Then in your django urls.py handle /admin
>
>
>
> On Jan 4, 9:15 pm, Nickolas Daskalou <n...@daskalou.com> wrote:
> > This is probably a pure Python question.
> >
> > Is it possible to use a different framework depending on what hostname
> the
> > request was made to? For example:
> >
> > api.mydomain.com (API service) -> webapp
> > admin.mydomain.com (Backend administration) -> app-engine-patch (AEP)
> >
> > The data model needs to be the same for each framework (worst case would
> > require a duplicated models.py file, which is ok).
> >
> > We want AEP for its admin capabilities for admin.mydomain.com, but we
> want
> > responses from api.mydomain.com to be as fast as possible so we'd prefer
> to
> > use webapp, which responds faster than AEP on "cold" requests (requests
> > where there is no app caching yet).
>
> --
> 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-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>
>
>
--
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-appeng...@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