[Grok-dev] setting up local utilities from outside grok
cklinger at novareto.de
Thu Jul 9 06:21:06 EDT 2009
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)
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...)
> 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,
> 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:
> root = get_apps_root() # this sets up the ZODB connection and returns the
> # root object
> if 'test' not in root:
> root['test'] = app = MyWonderfulApp(...)
> 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?
More information about the Grok-dev