[Grok-dev] Setting up a Grok app instance via buildout...
Jeffrey Peterson
bgpete at gmail.com
Thu Jun 14 16:36:29 UTC 2012
Thanks! Worked great.
Jeffrey Peterson
bgpete3 at gmail.com
On Jun 14, 2012, at 1:59 AM, Jan-Jaap Driessen wrote:
> On Wed, Jun 13, 2012 at 9:16 PM, Jeffrey Peterson <bgpete at gmail.com> wrote:
>> Is there any way to do this?
>>
>> Essentially I want to replicate setting up the instance in the Grok Admin UI
>> using buildout.
>>
>> TIA.
>
> Hi Jeffrey,
>
> We use zope.generations [1] for that.
>
> In yourpackage/evolution.py:
>
> """
> import grok
> from zope.generations.interfaces import IInstallableSchemaManager
> from zope.generations.utility import getRootFolder
> from zope.component.hooks import setSite
>
> class Evolution(grok.GlobalUtility):
> grok.name('your-descriptive-name')
> grok.implements(IInstallableSchemaManager)
>
> minimum_generation = generation = 1
>
> def install(self, context):
> root = getRootFolder(context)
> setSite(root)
> '''
> Your setup code goes here
> '''
>
> def evolve(self, context, generation):
> func = getattr(self, '_%s' % generation)
> func(getRootFolder(context))
>
> def _1(self, root):
> '''
> Your evolution code for v1 goes here.
> '''
> """
>
> And in configure.zcml:
>
> '''
> <!--
> applications typically like to have all evolutionary steps applied
> onto the application objects.
> -->
> <subscriber
> handler="zope.generations.generations.evolveSubscriber"
> for="zope.processlifetime.IDatabaseOpenedWithRoot"
> />
> '''
>
> The "install" code will be executed when the application is started
> with an empty ZODB. We use this point to set up fixtures and are not
> using grokui admin any longer.
>
> HTH,
>
> JJ
>
> 1) http://pypi.python.org/pypi/zope.generations
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.zope.org/pipermail/grok-dev/attachments/20120614/f67aeebb/attachment.html>
More information about the Grok-dev
mailing list