-----BEGIN PGP SIGNED MESSAGE-----
Martijn Faassen wrote:
> On 10/20/07, Lennart Regebro <[EMAIL PROTECTED]> wrote:
>> On 10/20/07, Martijn Faassen <[EMAIL PROTECTED]> wrote:
>>> I'd say it is a general concern of a framework to try to avoid how often
>>> you need to repeat yourself. Right now you to use a Zope 3 package you
>>> need to do the following things:
>>> * list the egg in your setup.py dependencies
>>> * load the ZCML required
>>> * import it in your code
>> True. But they do different things.
>> 1. Says "download and install a component"
>> 2. Says "configure a component"
>> 3. Says "use a component"
> Sure, they do different things. Nonetheless, there is repetition that
> could be reduced. In fact
> there's potentially a fourth place now where we reference dependency
> information again:
> 4. Use this version of this component
> (though this may be maintained outside of the actual package)
> In at least 3 places we express dependency information. For different
> *purposes* in each case, but we still state something like:
> 1. "we use dependency X, and please download and install it"
> 2. "we use dependency X, please configure it"
> 3. "we use dependency X, please import the following from it"
> It'd be nice if I only had to say "I want to import from dependency X,
> please make sure it's there and available."
setuptools spells that semantic so:
>>> import pkg_resources
>>> loaded = require('zope.interface 3.4.0')
At that point, the 'zope.interface' egg is guaranteed to be on sys.path,
and with the desired version: the subsequent:
>>> import zope.interface
will then come from that location. This presumes that you haven't
already hacked sys.path to include it from somewhere else ('requires'
appends entries there).
Note that if 'grok' itself explicitly pins all its requirements (the
"frozen egg" scenario), then just saying:
would have the effect of loading *all* the pinned requirements eggs onto
> Actually this is a little
> bit like zc.resourcelibrary can make resources appear on your page
> headers when you write code that needs it.
> Of course this is sometimes not possible, as there's not enough
> information available, or there are multiple separate ways to
> configure it.
> But there is significant repetition spread out across the codebase.
> It's not in one place, which forces a repetition in referring to the
> component being installed/configured/imported. My response is to think
> about ways to reduce this (while of course, looking for ways to retain
> power and flexibility).
If you expose an 'entry point group" for the automagic ZCML loader to
use, then you don't require any repetition in the client code, because
the plugin provide conforms to a standard interface which allows discovery::
# Assume that plugins register one or more entry points for the group,
# 'plone.automatic_zcml', where each entry point is a module name whose
# ZCML is to be loaded.
>>> from zope.configuration.xmlconfig import xmlconfig
>>> for ep in pkg_resources.iter_entry_points('plone.automatic_zcml'):
... module_name = ep.module_name
... # trigger ZCML loading here using 'module_name'
... stream = pkg_resources.resource_stream(module_name,
Tres Seaver +1 540-429-0999 [EMAIL PROTECTED]
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
Zope-Dev maillist - Zope-Dev@zope.org
** No cross posts or HTML encoding! **
(Related lists -