Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
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() 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
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, Jul 7, 2008 at 2:25 PM, Tim Cook <[EMAIL PROTECTED]> wrote: > Okay. But before I do that. Is my approach to initializing an instance > correct or is the problem the way I handled the keywords? ... >for n,v in kw.items(): >setattr(self,n,v) There are people who like this style and people who don't (and consider it ridiculously fragile), but zope.schema couldn't care less about this. -Fred -- Fred L. Drake, Jr. "Chaos is the score upon which reality is written." --Henry Miller ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
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. But before I do that. Is my approach to initializing an instance correct or is the problem the way I handled the keywords? class Activity(Locatable): """ A single activity within an instruction. """ implements(IActivity) def __init__(self,descr,tim,atid,nodeid,**kw): self.descript=descr self.timing=tim self.actionArchetypeId=atid self.__name__=nodeid for n,v in kw.items(): setattr(self,n,v) Thanks, Tim 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
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
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? -- Benji York Senior Software Engineer Zope Corporation ___ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users
Re: Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
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. The WrongType error occurs in validation because Zope thinks it is the 'description' of the attribute and not the attribute itself. Therfore it is expect a TextLine. So I guess this means that title,required etc won't work for attributes of classes either unless they are defined as the same type of the Zope attributes? Is this a bug in Zope or something I am just going to have to work around? Thanks, Tim On Mon, 2008-07-07 at 14:03 -0300, Tim Cook wrote: > On Mon, 2008-07-07 at 13:58 -0300, Tim Cook wrote: > > ... and I've learned a lot thanks to you patience. > > > > On Mon, 2008-07-07 at 12:41 -0300, Tim Cook wrote: > > > I've been Googling for a script I can run against all of my source to > > > test characters for unicode just in case there are more of those that I > > > copied into title or description fields. If you think of anything let > > > me know. Otherwise I may have to write one. > > > > So I wrote one and sure enough there was a non-printing non-unicode > > character in a description string. > > Seems I was a little premature. There was the character but I forgot > about a change I had made that caused the real problem not to show up. > It's still there. Sigh; back to the search. > > --Tim > > -- Timothy Cook, MSc Health Informatics Research & Development Services LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook Skype ID == timothy.cook ** *You may get my Public GPG key from popular keyservers or * *from this link http://timothywayne.cook.googlepages.com/home* ** 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
Not Really SOLVED! Re: [Zope3-Users] Re: zope.schema Question
On Mon, 2008-07-07 at 13:58 -0300, Tim Cook wrote: > ... and I've learned a lot thanks to you patience. > > On Mon, 2008-07-07 at 12:41 -0300, Tim Cook wrote: > > I've been Googling for a script I can run against all of my source to > > test characters for unicode just in case there are more of those that I > > copied into title or description fields. If you think of anything let > > me know. Otherwise I may have to write one. > > So I wrote one and sure enough there was a non-printing non-unicode > character in a description string. Seems I was a little premature. There was the character but I forgot about a change I had made that caused the real problem not to show up. It's still there. Sigh; back to the search. --Tim 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