[Interface-dev] zope.interface calling an interface with no
arguments
Daniel Krech
eikeon at eikeon.com
Wed Aug 31 23:22:44 EDT 2005
On Aug 31, 2005, at 10:32 PM, Fred Drake wrote:
> On 8/31/05, Daniel Krech <eikeon at eikeon.com> wrote:
>
>> We're in the process of adding Interfaces to rdflib using Zope
>> Interfaces and also replacing rdflib's home brewed plugin system. So
>>
>
> Very cool!
Forgot to mention I'm really liking the interfaces... not sure how
I've been coding in Python this long without them. Refreshing.
>> far things are going well, but we've run across something we'd like
>> to be able to do, namely, create an instance by calling the interface
>> with no arguments. For example:
>>
>
> This sounds like you're looking for more than just the interface
> definitions, but for something like the component architecture as well
> (zope.component).
True. Just keeping an eye on our dependencies. I'm thinking
zope.component will probably be our next dependency ;)
> The component architecture adds support for registries of objects that
> provide interfaces that can then be used as utilities. The model that
> we'd follow would be to define an interface for a *factory* that
> creates objects of particular types. A factory typically has one
> method (__call__), that takes whatever arguments are needed. If there
> are different sets of arguments that may be passed, several methods
> can be defined for the factory interface, or different factory
> interfaces can be defined. Code that wants to create objects of a
> certain interface looks up the corresponding factory interface (which
> it can do just once) and then use the factory to produce instances.
> Something like:
>
> factory = zope.component.getUtility(IThingFactory)
> thing_one = factory()
> thing_two = factory()
>
> This has been working well so far in Zope 3; I think we're all really
> happy with it. It might be worthwhile looking at zope.component from
> the Zope 3.1.0c2 release or from a Subversion checkout.
I'll take a look. Thank you.
>
> -Fred
>
> --
> Fred L. Drake, Jr. <fdrake at gmail.com>
> Zope Corporation
>
Daniel Krech, http://eikeon.com/
More information about the Interface-dev
mailing list