[Grok-dev] Recipe for "egg-like" reuse?

Uli Fouquet uli at gnufix.de
Tue Apr 8 11:33:49 EDT 2008


Hi Sebastian,

Sebastian Ware wrote:
> If I have written a Grok application that I would like to reuse in  
> another Grok application, how do I do this in an easy but still "egg- 
> like" way? (without having to publish an actual egg)

I assume both apps are grokprojects?

The following applies to currently released versions of
grokproject/grok. With the freshly created autoinclude feature this
might differ in future.

Change to the root of your new grok project. Let's assume it is called
MasterApp::

  $ cd MasterApp

Say, your 'inserted' app is named 'AddApp' and resides in
<some/path>/AddApp. Then copy the additional project into the MasterApp
root dir::

  $ cp -r <some/path>/AddApp .

If you're AddApp is in some subversion, you might consider to add an
svn:external instead.

Now edit buildout.cfg and add the new app as devel package::

  develop = . AddApp
  ...

Edit setup.py to require your AddApp::

  ...
  install_requires=['setuptools',
                    'grok',
                    # Add extra requirements here
                    'AddApp',
                        ],
  ...

Run buildout and you should be able to do::

  $ ./bin/zopectl debug
  >>> from addapp.app import AddApp

without error.

That might be enough, depending on what functionality you need from your
AddApp. If you need views etc. and all this should be registered
automatically on startup, go on.

If you want your AddApp to be registered completely, edit buildout.cfg
and register your additional app in the [app] section::

  ...
  [app]
  recipe = zc.zope3recipes>=0.5.3:application
  eggs = MasterApp
  site.zcml = <include package="masterapp" />
              <include package="addapp" /> <!-- NEW ENTRY -->
              <include package="zope.app.twisted" />
  ...

Rerun buildout, start your instance, be happy :-)

Hope that helps,

-- 
Uli

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://mail.zope.org/pipermail/grok-dev/attachments/20080408/5c0167f7/attachment.bin


More information about the Grok-dev mailing list