<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Thanks! &nbsp;Worked great.<div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div>Jeffrey Peterson</div><div><a href="mailto:bgpete3@gmail.com">bgpete3@gmail.com</a></div><div><br></div></span><br class="Apple-interchange-newline">
</div>
<br><div><div>On Jun 14, 2012, at 1:59 AM, Jan-Jaap Driessen wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Wed, Jun 13, 2012 at 9:16 PM, Jeffrey Peterson &lt;<a href="mailto:bgpete@gmail.com">bgpete@gmail.com</a>&gt; wrote:<br><blockquote type="cite">Is there any way to do this?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Essentially I want to replicate setting up the instance in the Grok Admin UI<br></blockquote><blockquote type="cite">using buildout.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">TIA.<br></blockquote><br>Hi Jeffrey,<br><br>We use zope.generations [1] for that.<br><br>In yourpackage/evolution.py:<br><br>"""<br>import grok<br>from zope.generations.interfaces import IInstallableSchemaManager<br>from zope.generations.utility import getRootFolder<br>from zope.component.hooks import setSite<br><br>class Evolution(grok.GlobalUtility):<br> &nbsp;&nbsp;&nbsp;grok.name('your-descriptive-name')<br> &nbsp;&nbsp;&nbsp;grok.implements(IInstallableSchemaManager)<br><br> &nbsp;&nbsp;&nbsp;minimum_generation = generation = 1<br><br> &nbsp;&nbsp;&nbsp;def install(self, context):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;root = getRootFolder(context)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setSite(root)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your setup code goes here<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''<br><br> &nbsp;&nbsp;&nbsp;def evolve(self, context, generation):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func = getattr(self, '_%s' % generation)<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;func(getRootFolder(context))<br><br> &nbsp;&nbsp;&nbsp;def _1(self, root):<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your evolution code for v1 goes here.<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''<br>"""<br><br>And in configure.zcml:<br><br>'''<br>&lt;!--<br>applications typically like to have all evolutionary steps applied<br>onto the application objects.<br>--&gt;<br>&lt;subscriber<br> &nbsp;handler="zope.generations.generations.evolveSubscriber"<br> &nbsp;for="zope.processlifetime.IDatabaseOpenedWithRoot"<br>/&gt;<br>'''<br><br>The "install" code will be executed when the application is started<br>with an empty ZODB. We use this point to set up fixtures and are not<br>using grokui admin any longer.<br><br>HTH,<br><br>JJ<br><br>1) <a href="http://pypi.python.org/pypi/zope.generations">http://pypi.python.org/pypi/zope.generations</a><br></div></blockquote></div><br></div></body></html>