On Thu, Jan 22, 2009 at 2:15 PM, James <[email protected]> wrote: > > Hi all, > What's the best way for me to create two "applications" in one TG > project? > > I have a working user-facing TG application which needs to stay as-is > (for the most part). What I need is an admin application that uses the > exact same model and configuration as the existing application. > > Simply adding the admin functionality to a separate controller on the > user app won't work for me: there are hundreds of instances of the > user app while I need exactly one admin app, and it will various > scheduled tasks that I don't want running on the existing user > application. > > A passable alternative would be to use svn:externals to 'import' the > existing model definition and configuration files into a completely > separate new app, but it seems a fairly clunky solution... > > My ideal scenario is to have a new top-level module with its own > controllers, templates, static content, etc., but which uses the model > from the existing user application. > > My efforts so far have been to manually create this module, and point > the admin app at the existing model from app.cfg, e.g.: > identity.provider='sqlalchemy' > identity.saprovider.model.user="user_app.model.User" > > With this set-up: > - identity.provider is set properly when running the second > application, but attempt to use @identity.require cause the server to > hang and I need to kill -9 > - when running JUST the new app's unit tests, identity.provider is NOT > set, and nothing works (RequestRequiredException when creating Users) > - when running BOTH the new app's and existing apps' tests, > identity.provider is set as expected > > There is a passing mention here: > http://docs.turbogears.org/1.0/CreatingBigApplications > "TurboGears expects that there is a loadable module in > <yourpackage>.model", which I don't have... > > Is there any way for me to have two distinct controller / view stacks > on top of one model? > you have many ways to tackle this. The first step is what you point out, you need a "model package"
Now if you give it a little setup you could do wonders, there is this thing call "namespace package" whic his simply a package which is build out of other packages. So you will have 3 packages which are "all your application", lets call it webbuilder 1- webbuilder.model 2- webuilder.app 3- webbuilder.admin 2 and 3 will depend (both setup.py) and import from 1 so everything that's common goes there. As a bonus webbuilder.model is standalone so you could even build a cli for it or some GUI other client or what not. Chris Perkins has a great explanation on how to convert your project over to namespaces http://percious.com/blog/archives/13 If this is a new project I'll recommend you try it out with tg2, I have a running project with this setup, I never had the change with tg1... hope that helps --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

