Re: [Zope3-dev] Re: a new zcml directive?

2006-03-17 Thread Martijn Faassen
Martijn Faassen wrote: [snip Jim helping me] Okay, that's one step closer to support for this in the annotation package, thanks! I've checked this in last night. There's a README.txt in zope.app.annotation now too that explains its usage. Regards, Martijn

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Martijn Faassen
Philipp von Weitershausen wrote: Martijn Faassen wrote: I stand by my conclusions on this approach sounding simple in theory, but still being a bit harder than it should be in practice. :) I think this is pretty simple: def makeAnnotationAdapter(for_, factory, key):

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Jean-Marc Orliaguet
Martijn Faassen wrote: Philipp von Weitershausen wrote: Martijn Faassen wrote: I stand by my conclusions on this approach sounding simple in theory, but still being a bit harder than it should be in practice. :) I think this is pretty simple: def makeAnnotationAdapter(for_, factory,

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Martijn Faassen
Jean-Marc Orliaguet wrote: [snip] excuse me, but can someone explain what problem the pattern / workaround is supposed to fix, does it create and return a default annotation value in case an annotation key does not exist? shouldn't the annotation machinery be fixed instead to provide

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Jean-Marc Orliaguet
Martijn Faassen wrote: Jean-Marc Orliaguet wrote: [snip] excuse me, but can someone explain what problem the pattern / workaround is supposed to fix, does it create and return a default annotation value in case an annotation key does not exist? shouldn't the annotation machinery be fixed

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Martijn Faassen
Jean-Marc Orliaguet wrote: [snip] OK, basically you mean that the 'annotations' given in your original post should implement a 'setdefault' method? I don't see how that would help - you'd still end up writing a factory that uses the setdefault, right? I don't want to keep repeating factory

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-16 Thread Jean-Marc Orliaguet
Martijn Faassen wrote: Jean-Marc Orliaguet wrote: [snip] OK, basically you mean that the 'annotations' given in your original post should implement a 'setdefault' method? I don't see how that would help - you'd still end up writing a factory that uses the setdefault, right? I don't want

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Martijn Faassen
Jim Fulton wrote: Philipp von Weitershausen wrote: Marius Gedminas wrote: I'd prefer from zope.annotation.adapter import AnnotationAdapter getFoo = AnnotationAdapter(for_=IBar, interface=IFoo, factory=Foo,

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Martijn Faassen
Jim Fulton wrote: Martijn Faassen wrote: ... I just tried to write AnnotationAdapter. Unfortunately, I haven't gotten very far yet, as it turns out I need to understand the internals of the implementation of the zope:adapter ZCML statement. No, you don't. zope:adapter has a bunch of

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Jim Fulton
Martijn Faassen wrote: Jim Fulton wrote: ... If a factory is not a class, and if it allows attributes to be set on it, then the interface.implementor function can be used to make declarations for it. This is documeted in zope/interfaces/README.txt and zope/component/README.txt.

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Martijn Faassen
Jim Fulton wrote: Martijn Faassen wrote: Jim Fulton wrote: This is one bit I was missing, thanks. Unfortunately I read in zope/interface/README.txt that the 'implementer' function cannot be used for classes yet, so this will change the design somewhat (I was using __call__, looks like

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Jim Fulton
Martijn Faassen wrote: ... Then this and the __component_adapts__ hack should be enough to make it work (still an unpleasant hack, that). Huh? Use adapter. class FactoryFactory: def __init__(self): # initialize a new factory ... implementer(self,

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Martijn Faassen
Jim Fulton wrote: Martijn Faassen wrote: ... Then this and the __component_adapts__ hack should be enough to make it work (still an unpleasant hack, that). Huh? Use adapter. class FactoryFactory: def __init__(self): # initialize a new factory ...

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Jeff Shell
On 3/15/06, Martijn Faassen [EMAIL PROTECTED] wrote: In the new world for ZCML, ZCML as a language falls apart in a minimalistic XML language, and some support code (such as zope.app.annotation.AnnotationFactory) to help it do more advanced things. That's what I'd like to see! :) One

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-15 Thread Philipp von Weitershausen
Martijn Faassen wrote: I stand by my conclusions on this approach sounding simple in theory, but still being a bit harder than it should be in practice. :) I think this is pretty simple: def makeAnnotationAdapter(for_, factory, key): @zope.component.adapter(for_)

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-14 Thread Jim Fulton
Philipp von Weitershausen wrote: Marius Gedminas wrote: I'd prefer from zope.annotation.adapter import AnnotationAdapter getFoo = AnnotationAdapter(for_=IBar, interface=IFoo, factory=Foo,

[Zope3-dev] Re: a new zcml directive?

2006-03-13 Thread Philipp von Weitershausen
Lennart Regebro wrote: On 3/10/06, Martijn Faassen [EMAIL PROTECTED] wrote: For instance, one that looks like this: zope:annotation for=IBar factory=Foo / That doesn't look like configuration. No, it's an on/off switch. Me likesss it. Philipp

[Zope3-dev] Re: a new zcml directive?

2006-03-13 Thread Philipp von Weitershausen
Marius Gedminas wrote: I'd prefer from zope.annotation.adapter import AnnotationAdapter getFoo = AnnotationAdapter(for_=IBar, interface=IFoo, factory=Foo, key=FOO_KEY) # I suppose

[Zope3-dev] Re: a new zcml directive?

2006-03-12 Thread Martin Aspeli
On Sat, 11 Mar 2006 00:49:19 -, Marius Gedminas [EMAIL PROTECTED] wrote: I think this is exactly the same as Jeff Shell's suggestion, but its 3am, and I'm too tired to read his entire message. I find I have that problem even at more sociable hours of the day (depending on whom you

[Zope3-dev] Re: a new zcml directive?

2006-03-10 Thread Rocky Burt
On Fri, 2006-10-03 at 17:17 -0700, Jeff Shell wrote: But I beg you not to add to the ZCML pile because you had to copy and paste 12 lines of Python code. snip... I haven't personally formed an opinion on where this sort of thing should go, but copying and pasting 12 lines of python code is

Re: [Zope3-dev] Re: a new zcml directive?

2006-03-10 Thread Shane Hathaway
Rocky Burt wrote: On Fri, 2006-10-03 at 17:17 -0700, Jeff Shell wrote: But I beg you not to add to the ZCML pile because you had to copy and paste 12 lines of Python code. snip... I haven't personally formed an opinion on where this sort of thing should go, but copying and pasting 12 lines