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 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-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 c

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] 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 getAnn

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, key)

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): @zope.component.adapter

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_) @zope.interface.implement

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

Dissecting NamedTemplate (was Re: [Zope3-dev] Re: a new zcml directive?)

2006-03-15 Thread Jeff Shell
Another long post, where below I take apart zope.formlib.namedtemplate, hoping it can be used as a source of insight into how to provide flexible extensibility (like in this example AnnotationsAdapter concept) without needing yet-another-ZCML-directive. On 3/15/06, Martijn Faassen <[EMAIL PROTECTE

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 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, s

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 I'l

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: ... 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 automat

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

2006-03-15 Thread Jim Fulton
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 automation to look for the

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-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, key=FOO_K

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. ... > > I haven't personally formed an opinion on where this sort of thing > should go, but copying and pasting 12 li