[Zope-dev] Zope guru help needed (or become guru if you help me)

Martijn Faassen faassen@vet.uu.nl
Sun, 5 Dec 1999 17:57:55 +0100


Pavlos Christoforou wrote:
> A few non guruish comments.

Those are very welcome as well, of course. Maybe a few non-gurus
can manage to figure it out as well. :)

> On Sat, 4 Dec 1999, Martijn Faassen wrote:
> 
> > differently for each field that is added. Because I could not figure out 
> > a way to pass extra information to the HTMLFile object when it's called,
> > I decided not to use them, and wrote a custom class instead to produce
> > the right form.
> 
> You mean you could not pass extra info in terms of keword arguments or
> that was not an option?

I don't know how. I can pass on keyword arguments when constructing
a HTMLFile() object, if I construct 3 HTMLFile objects from the same file
(fieldAdd.dtml), all three take on the keyword arguments of the last
such construction, i.e.:

a = HTMLFile('fieldAdd', globals(), fieldname="Foo")
b = HTMLFile('fieldAdd', globals(), fieldname="Bar")
c = HTMLFile('fieldAdd', globals(), fieldname="Baz")

now, methods a, b and c all use fieldname 'Baz', for some reason.

I don't know if this is a Zope bug or not..

I can't pass on keyword arguments later on when the methods are used, 
as they're called from Zope itself. So if that's possible I don't know how.

[snip __roles__]
> The __roles__ (or <method>___roles__) attribute is the fundamental
> attribute that holds the roles info for each method, class etc. (unless
> things changed radically in later versions. If you are not using
> ZPublisher directly you shouldn't need to mess with it.

I am manually adding 'FormHack' as a method to the Form class. FormHack is
just a simple Python class. I assume HTMLFile derives from the right 
Zope classes so that it knows about __roles__, but FormHack doesn't.

> Then again you are trying to do pretty unusual stuff so you might need an
> unusual solution ;-)

Right, this is all an attempt to reduce code duplication and to shield the
Python programmer from lots of Zope's machinery, while creating new field
subclasses. In this regard it's successful.

> I haven't offered much help, but if I get some time tonight I will read
> Form.py.

Thanks, let's hope sufficient eyeballs indeed make all bugs shallow. :)

Regards,

Martijn