|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
setting up local utilities from outside grokHi list,
I've got a small issue with setting up local utilities on a grok.Application; I have something like the following: class MyWonderfulApp(grok.Application): grok.local_utility(PluggableAuthentication, provides=IAuthentication, setup=setup_authentication) This works fine if I instantiate my application through the webinterface. However, I'd like to be able to instantiate my application using some code (which doesn't know a lot about grok), where I do something like: grok.grok('my.app') root = get_apps_root() # this sets up the ZODB connection and returns the # root object if 'test' not in root: root['test'] = app = MyWonderfulApp(...) ... transaction.commit() The application is available, I can access views, but no sitemanager or localutil is registered, and my authentication thing is not set up. Is there an easy way to get this to work? Cheers, -- Jasper Spaans Fox-IT Experts in IT Security! I www.fox-it.com _______________________________________________ Grok-dev mailing list Grok-dev@... http://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: setting up local utilities from outside grokHi Jasper,
maybe you can look on zope.app.generation. I am not 100 % sure if your usecase is doable with that package. I try to give you a little code snippet which maybe works... 1. Add a directory called 'generations' in your package. 2. put this snippet into the generations/__init__.py: from zope.app.generations.generations import SchemaManager UVCSchemaManager = SchemaManager( minimum_generation = 1, generation = 2, package_name = __name__ ) 3. Add an generations/install.py file with this content: (Note this file gets called exactly 1 times on startup of zope) import zope.app.generations.utility def evolve(context): print "Install Generation" root = zope.app.generations.utility.getRootFolder(context) #do your stuff here.... Hope this helps. Please let me know if it works for you. (Because i have the same problem but no time to tackle it...) - Christian > Hi list, > > I've got a small issue with setting up local utilities on a > grok.Application; I have something like the following: > > class MyWonderfulApp(grok.Application): > grok.local_utility(PluggableAuthentication, provides=IAuthentication, > setup=setup_authentication) > > This works fine if I instantiate my application through the webinterface. > However, I'd like to be able to instantiate my application using some code > (which doesn't know a lot about grok), where I do something like: > > > grok.grok('my.app') > root = get_apps_root() # this sets up the ZODB connection and returns the > # root object > > if 'test' not in root: > root['test'] = app = MyWonderfulApp(...) > ... > transaction.commit() > > The application is available, I can access views, but no sitemanager or > localutil is registered, and my authentication thing is not set up. > > Is there an easy way to get this to work? > > Cheers, _______________________________________________ Grok-dev mailing list Grok-dev@... http://mail.zope.org/mailman/listinfo/grok-dev |
|
|
Re: setting up local utilities from outside grokOn Jul 9, 2:55 am, Jasper Spaans <j...@...> wrote: > > The application is available, I can access views, but no sitemanager or > localutil is registered, and my authentication thing is not set up. > > Is there an easy way to get this to work? > Take a look at site.txt in the zope.app.component for documentation on sites. When instantiating a Grok app outside Grok, I think you need to explicity set the site with zope.app.component.hooks.setSite(): import zope.app.component.hooks root['test'] = app = MyWonderfulApp(...) zope.app.component.hooks.setSite(root['test']) Then your local components should work as-expected (hopefully ... the sites stuff is not my area of expertise) _______________________________________________ Grok-dev mailing list Grok-dev@... http://mail.zope.org/mailman/listinfo/grok-dev |
| Free embeddable forum powered by Nabble | Forum Help |