Hi there, I'm having some problems with ZClasses within an ObjectManager ZClass. [later: ahum, I *had *some problems. I'll leave this mail as an interesting debugging artifact; it perhaps also points out some bugs in Zope] * What am I trying to do? I have a FormulatorForm ZClass. Instances of FormulatorForm can contain instances of ZClasses (IntegerField, StringField, etc). Those field ZClasses should only be able to create inside FormulatorForm instances, nowhere else. * How far did I get? I have created a ZClass FormulatorForm. Inside I've created my Field ZClasses (4 of them right now). I've also let Zope autogenerate the constructor methods. This all appears to work. * What is wrong then? First I had created the Field ZClasses as global ZClasses; they could be created anywhere. I tried to move them inside the new FormulatorForm ZClass, and this worked; only the permissions wouldn't move from the root of the Product. It all seemed to work, but the field ZClasses show up *twice* each in the add list of a FormulatorForm instance. I messed around a bit with creating and disabling factories, permissions, I forget what. I had one field ZClass show up only once then, but then I got an error when trying to add it. Not daunted, I removed all Field ZClasses and added them again from scratch (not a big deal as they were mostly inheriting from Python base classes). My experimenting, I thought, showed that this would fix the problems. Nada. They still show up twice. What do I do now? * What did you do to solve the problem? (added after I wrote the above and I started figuring things out on my own) Ooh, wait, I have just noticed that when I add a ZClass by hand which doesn't inherit from any Python base class, the problem does not occur. And *now* I have figured out that I should not name the Python base classes the same as the ZClasses (my Python base class is called StringField, while the ZClass inheriting from it is also called that). This seems to be the source of the problem. Do not give your ZClass the same name as the Python base class it inherits from! This appears to be, if not a Zope bug, at least a severe Zope unclarity. Having created a ZClass with a different name, all works, except that I run into the resource not found bug (I did *not* run into that one before with my other bug! :). Luckily there's a howto on how to fix that, which worked: http://www.zope.org/Members/gtk/containers Phew. I hope the Zope version in CVS fixes both problems. :) Regards, Martijn
[snip my struggle with ZClasses that derive from Python base classes inside ZClasses] Okay, this *still* didn't work; apparently the ObjectManager ZClass was somehow put into a wrong state -- even if I deleted the old field ZClasses (for instance IntegerField), it would still show up in the add list -- probably because it could find an IntegerField Python base class? Anyway, I created a while new ObjectManager ZClass, created a while new Field class inside, and now it seems to work properly. I hope this kind of ZClass weirdness is fixed in the CVS version of Zope; if not read my mails for the symptoms. It can get very confusing and frustrating. But-I-suppose-I'm-the-only-guy-deriving-ZClasses-from-his-Python-base-classes-ly yours, Regards, Martijn
On Wed, 27 Oct 1999, Martijn Faassen wrote:
But-I-suppose-I'm-the-only-guy-deriving-ZClasses-from-his-Python-base-classes-ly
Your not! The above was the reason why my ZClasses are different from my Python SuperClass. It is also much easier during development to have the ZClasses and Python Superclasses as separate Products. I promise a new version of VisualZope will be out in 4 weeks time ;) (unless I find more bugs ;) Cheers, Anthony Pfrunder
participants (2)
-
Anthony Pfrunder -
Martijn Faassen