On Mon, 2008-07-07 at 13:34 -0400, Benji York wrote:
> On Mon, Jul 7, 2008 at 1:28 PM, Tim Cook <[EMAIL PROTECTED]> wrote:
> >
> > Okay, the problem is defined but it really isn't a solution for me.
> > It seems that Zope has defined 'description' as a keyword not allowed in
> > schema definitions.
> 
> That's rather odd.  Can you construct a small example (say, a
> stand-alone .py file) that demonstrates the problem?


Okay, this demonstrates the problem.  But now I know it's my code.
Benji may recall answering another problem I had with:
zope.interface.exceptions.InvalidInterface: Concrete attribute,
Where he said one of the class didn't but should inherit from Field. 

So, I now have several ancestor classes (all the ones that used to
inherit from object) that now inherit from Field.  It appears I was
careless in making these choices.  

If TestB inherits from Field and TestA inherits from object (current
state) or both inherit from Field the problem appears. 

If TestB inherits from object and TestA inherits from Field or both
inherit from object or you change the name of the TestB.description
attribute the error goes away.

Now it is probably obvious by now that I have no idea what is going on
here so if someone has time to add a little Zen i would appreciate it
since it will help me unscrew my inheritance tree.  :-)

Cheers,
Tim

---------------------------------------------------------------------------
# descr.py -- test behaviour of the Zope schema when using field names
as class attributes.

from zope.interface import Interface,implements
from zope.schema import Field,Object

class ITestA(Interface):
    
    one=Field(
        title=u"one",
        description=u"one"
    )
    
class TestA(object):
    
    def __init__(self,num):
        self.one=num
        
class ITestB(Interface):
    
    two=Field(
        title=u"two",
        description=u"two"
    )
        
    description=Object(
        schema=ITestA,
        title=u"descrption",
        description=u"description"
    )
    
class TestB(Field):
    
    def __init__(self,num,descr):
        self.two=num
        self.description=descr
        
        
def buildit():
    a=TestA(1)
    print a.one
    
    b=TestB(2,a)
    print b.two
    print b.description
    
if __name__ == "__main__":
    buildit()
        
---------------------------------------------------------------------------

# descr.py -- test behaviour of the Zope schema when using field names as class attributes.

from zope.interface import Interface,implements
from zope.schema import Field,Object

class ITestA(Interface):
    
    one=Field(
        title=u"one",
        description=u"one"
    )
    
class TestA(object):
    
    def __init__(self,num):
        self.one=num
        
class ITestB(Interface):
    
    two=Field(
        title=u"two",
        description=u"two"
    )
        
    description=Object(
        schema=ITestA,
        title=u"descrption",
        description=u"description"
    )
    
class TestB(Field):
    
    def __init__(self,num,descr):
        self.two=num
        self.description=descr
        
        
def buildit():
    a=TestA(1)
    print a.one
    
    b=TestB(2,a)
    print b.two
    print b.description
    
if __name__ == "__main__":
    buildit()
        

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to