[Grok-dev] building desktop applications with Zope and Grok

Lacko Roman rlacko at gratex.com
Fri Dec 5 03:41:21 EST 2008

After successful integration of grokcore.component in my project (thanks to Martijn's example),
I decided that the next step will be the integration of grokcore.security.

But after installing it with easy_install, I was little disappointed, founding that grokcore.security have too many dependencies - exactly 80 packages get downloaded ! This is 29 Mb (+/-) of code. For example there are such dependencies like ZODB, zope.pagetemplate, zope.app.*

I still think that using grokcore.security is the best way for me, and i don't want to reinvent the Wheel.

So, my question is: Is it possible (and how) to reduce dependencies of grokcore.security ?

Perhaps i am first who wan't to use Zope to build desktop apllication, and no one has this size-of-installed-packages problem,
I understand that when using Zope for web development, size does not mater, because source code is saved on server - but in desktop applications this is realy problem

Thank you for any help


-----Original Message-----
From: grok-dev-bounces at zope.org [mailto:grok-dev-bounces at zope.org] On Behalf Of Martijn Faassen
Sent: Wednesday, December 03, 2008 5:16 PM
To: grok-dev at zope.org
Subject: Re: [Grok-dev] grokcore.component in non-web application


Lacko Roman wrote:
> In past project I used grok framework to build my web application, and I
> must say I was impressed.

We're very happy to hear that!

> Zope's Component Architecture (ZCA) was exactly the missing future in my
> python world J
> Now I'm developing some desktop applications (one using wxPython,
> another with Mozilla+PyXPCOM extensions) and I definitely want to use
> ZCA,  grokcore.component seems to be the perfect choice.
> But I have some questions about using ZCA, especially howto use
> Component Registries.
> My question is: is there some examples of using ZCA/grokcore.component
> outside of zope server ?

I'll give you a code example. Perhaps you can contribute a document for
grok.zope.org (or the grokcore.component documentation) so that others
can find out how to do it.

You make your python project depend on grokcore.component in its
setup.py. This should pull in the right dependencies already.

Then in your own code:

from zope.configuration import xmlconfig

def main():
     import mypackage
     xmlconfig.file('configure.zcml', package=mypackage)

This will try to process the 'configure.zcml' file in the package
'mypackage' (which should be your project's Python package). This code
should run at startup time of your application.

In configure.zcml, place the following


   <include package="grokcore.component" file="meta.zcml" />

   <grok:grok package="." />


This will first make sure that grokcore.component is registered (through
the include of its 'meta.zcml', and then will grok your own package,
looking for anything that subclasses from grokcore.component's base
components (such as grokcore.component.Adapter).

So now you can start using grokcore.component.Adapter and the like in
your codebase and it should work.

If you have multiple packages, you would have your main package do an
'include' of all its dependencies. Or you could look at z3c.autoinclude
which can do it for you based on the dependencies listed in setup.py -
that should result in a configure.zcml that you shouldn't have to modify

> I understand that components are registered when modules are groked, and
> that there are methods like grok.testing.grok/ grok.testing.grok_component
> But I don't exactly now when and how to use them.

The grokcore.component.testing.grok function allows you to Grok
individual classes and instances within your tests. If you want to know
more I'll look for examples too.

I hope this works for you!



Grok-dev mailing list
Grok-dev at zope.org

More information about the Grok-dev mailing list