The class/__new__ trick isn't the only way to implement a proxy - a function works just as well.
If the handlers for several pages are in the same file, one can use a single proxy for all of them. Replace import file1 and ('/pathn', PathnPage) with ('/pathn', File1Proxy('PathnPage')) and def File1Proxy(name): def call(*args, **kwds): import file1 return getattr(file1, name)(*args, **kwds) return call I still don't know how to write a proxy that takes the file as a parameter. On Mar 27, 6:38 pm, Andy Freeman <ana...@earthlink.net> wrote: > It's "easy enough" to load the relevant part of the framework after > the dispatch. > > Use ('/path', Proxy) instead of ('/path', Real) and in a module that > does not load any of your framework, define Proxy as: > > class Proxy(object): > def __new__(cls, *args, **kwds): > from file import Real > return Real(*args, **kwds) > > That definition of Proxy assumes that file contains Real's definition. > > Someone who actually knows Python might be able to come up with a > generic proxy. Me, I'd need decent macros. > > On Mar 27, 1:19 pm, cz <czer...@gmail.com> wrote: > > > > > The problem with the app.yaml solution is that only the handler that > > has a main() will be cached (I assume that the app cache expects just > > one main() per app). It would be possible to perform a dispatch in main > > () to different handlers but it gets a little more messy since you > > would have to do this before referencing or loading any frameworks > > (unless the handlers all share the same framework in which case this > > discussion is moot). > > From what I understand, versions can have arbitrary names (not just > > numbers) so versions are, in a sense, just different apps that share > > quotas and datastore. Only the default can be associated with a Google > > app domain though. Otherwise the version name is basically another > > kind of app name, which makes it possible to have multiple main()'s > > and a mix of frameworks that can be optimized for certain kinds of > > requests. It also makes the code a little more straightforward... > > - Claude > > > On Mar 26, 11:46 pm, Robert <rjaa...@gmail.com> wrote: > > > > Hi, > > > > you could also in your app.yaml simply define a dedicated/different > > > handler for e.g. those images as they presumably are all under another > > > URL. Then you don't need to think/worry so much about different > > > versions. > > > > Just my 2cts. > > > > Robert > > > > On Mar 27, 12:50 am, "Tom M." <thomasfmc...@gmail.com> wrote: > > > > > A very clever solution. > > > > > On Mar 26, 6:31 pm, cz <czer...@gmail.com> wrote: > > > > > > Awesome, thanks Jeff. I think doing it this way would make my app use > > > > > less resources in general which is good for everybody. > > > > > - Claude > > > > > > On Mar 26, 2:25 pm, Jeff S <j...@google.com> wrote: > > > > > > > Hi Claude, > > > > > > > On Mar 25, 8:27 pm, cz <czer...@gmail.com> wrote: > > > > > > > > The reason I ask this is for the following scenario: > > > > > > > My main app uses Django 1.x and has fairly low, but quite useful > > > > > > > ;), > > > > > > > traffic thus often requiring a cold start. It incurs significant > > > > > > > startup time and so the initial requests are quite slow. The pages > > > > > > > also contain lots of images uploaded by users which in turn are > > > > > > > initially very slow to serve up. > > > > > > > What I'd like to do is use a lighter weight framework just to > > > > > > > serve > > > > > > > images and other pseudo-static content. It would be fairly > > > > > > > straightforward to simply create a special version of the app that > > > > > > > when installed has direct access to the same datastore and can be > > > > > > > very > > > > > > > fast. This wouldn't ever be set as the default version of course, > > > > > > > but > > > > > > > would still be 'a part of' the default app and it would be using > > > > > > > the > > > > > > > same quota bank and hopefully wouldn't be a violation of the TOS. > > > > > > > Anways, after reading the TOS I couldn't find an answer to this. > > > > > > > > So, in case none of this makes much sense the gist of the > > > > > > > question is > > > > > > > can I have two versions of the app live at the same time (only one > > > > > > > being the default)? > > > > > > > Say my app id is 'foo'. I upload 'foo' version 5 and then I also > > > > > > > upload a 'foo' version 6 with a different main.py and code that is > > > > > > > optimized for a specific kind of content (eg. images, no > > > > > > > templates). > > > > > > > Version 5 is set as the default but generates pages with image > > > > > > > urls > > > > > > > that point to version 6. > > > > > > > This would be fine since you are talking about using two versions > > > > > > under the same app ID. Quotas are applied based on the app ID (not > > > > > > further down on the version level), so sending traffic to multiple > > > > > > versions would be pulling from the same quota pool. > > > > > > > Good question, > > > > > > > Jeff > > > > > > > > Can I do this under the TOS and still be a good GAE citizen? > > > > > > > > thanks, > > > > > > > - Claude- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---