[Zope-dev] Referring to same interface using zope.schema.Object
Hello, I am trying to construct an object tree. Every node in the tree is of the same type. I am trying to achieve something like: class INode(Interface): parent = Object( title=u"Parent node", schema=INode ) children = List( title=u'Child nodes', value_type=Object(schema=INode) ) The above fails with "NameError: name 'INode' is not defined". Any clues as to how to solve this? Regards, Joe -- Joe Steeve HiPro IT Solutions Pvt. Ltd. http://hipro.co.in/ signature.asc Description: This is a digitally signed message part ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Referring to same interface using zope.schema.Object
On Fri, Jul 22, 2011 at 04:29:32PM +0530, Joe Steeve wrote: > Hello, > > I am trying to construct an object tree. Every node in the tree is of > the same type. I am trying to achieve something like: > > class INode(Interface): > > parent = Object( > title=u"Parent node", > schema=INode > ) > > children = List( > title=u'Child nodes', > value_type=Object(schema=INode) > ) > > The above fails with "NameError: name 'INode' is not defined". Any clues > as to how to solve this? This would be my first guess: class INode(Interface): pass INode.parent = Object( title=u"Parent node", schema=INode ) INode.children = List( title=u'Child nodes', value_type=Object(schema=INode) ) -- Brian Sutherland ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Referring to same interface using zope.schema.Object
On 2011-07-22 13:26, Brian Sutherland wrote: > This would be my first guess: > > class INode(Interface): > pass > > INode.parent = Object( > title=u"Parent node", > schema=INode > ) > > INode.children = List( > title=u'Child nodes', > value_type=Object(schema=INode) > ) > And that guess would be wrong. You can't add fields to an existing schema like that (not sure if you can in other ways). You *can* change an existing field however, so a working solution would be: class INode(Interface): parent = Object( title = u'Parent node', schema = Interface, # set to INode later ) children = List( title = u'Child nodes', value_type = Object(schema=Interface), # set to INode later ) INode['parent'].schema = INode INode['children'].value_type.schema = INode Hope this helps - Jacob ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] [BlueBream] Referring to same interface using zope.schema.Object
Hello, On Fri, 2011-07-22 at 13:41 +0200, Jacob Holm wrote: > On 2011-07-22 13:26, Brian Sutherland wrote: > > This would be my first guess: > > > > class INode(Interface): > > pass > > > > INode.parent = Object( > > title=u"Parent node", > > schema=INode > > ) > > > > INode.children = List( > > title=u'Child nodes', > > value_type=Object(schema=INode) > > ) > > > The method suggested by Brian works without any issues. :) > > And that guess would be wrong. You can't add fields to an existing > schema like that (not sure if you can in other ways). You *can* > change > an existing field however, so a working solution would be: > > class INode(Interface): > > parent = Object( > title = u'Parent node', > schema = Interface, # set to INode later > ) > > children = List( > title = u'Child nodes', > value_type = Object(schema=Interface), > ) > > INode['parent'].schema = INode > INode['children'].value_type.schema = INode I thought this also should work without any issues. But when I ran the debug shell to list out the attributes of INode using dir(INode) I couldn't find the 'parent' and 'children' attributes in it. Even worse part is, if there is another field say name = TextLine(title=u'Node name') This 'name' attribute is also is not visible along with 'parent' and 'children' attributes. Can someone explain why is this so? (Even though the problem gets solved by Brian's method, just curious to know) -- Joshua Immanuel HiPro IT Solutions Private Limited http://hipro.co.in signature.asc Description: This is a digitally signed message part ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] [BlueBream] Referring to same interface using zope.schema.Object
On 2011-07-22 14:32, Joshua Immanuel wrote: > Hello, > > On Fri, 2011-07-22 at 13:41 +0200, Jacob Holm wrote: >> On 2011-07-22 13:26, Brian Sutherland wrote: >>> This would be my first guess: >>> >>> class INode(Interface): >>> pass >>> >>> INode.parent = Object( >>> title=u"Parent node", >>> schema=INode >>> ) >>> >>> INode.children = List( >>> title=u'Child nodes', >>> value_type=Object(schema=INode) >>> ) >>> >> > > The method suggested by Brian works without any issues. :) > It "works" only in the the sense that it doesn't throw an exception. It does not define the desired schema. >> >> And that guess would be wrong. You can't add fields to an existing >> schema like that (not sure if you can in other ways). You *can* >> change >> an existing field however, so a working solution would be: >> >> class INode(Interface): >> >> parent = Object( >> title = u'Parent node', >> schema = Interface, # set to INode later >> ) >> >> children = List( >> title = u'Child nodes', >> value_type = Object(schema=Interface), >> ) >> >> INode['parent'].schema = INode >> INode['children'].value_type.schema = INode > > I thought this also should work without any issues. Trust me, it does. > But when I ran the > debug shell to list out the attributes of INode using dir(INode) I > couldn't find the 'parent' and 'children' attributes in it. The fields of the schema are not *supposed* to show up in "dir()". Despite the use of the "class" statement to define them, interfaces are *not* classes. They are instances of zope.interface.interface.InterfaceClass, and act like (read-only) containers of their fields. Try using 'list(Inode)' for testing and you will see that "my" method works as expected. > Even worse > part is, if there is another field say > > name = TextLine(title=u'Node name') > > This 'name' attribute is also is not visible along with 'parent' and > 'children' attributes. > > Can someone explain why is this so? > Right. As explained above, it isn't supposed to. > (Even though the problem gets solved by Brian's method, just curious to > know) > I hope to have convinced you by now that it really isn't solved by Brian's method, but by mine. (Although I wouldn't call it "my" method as such. I'm sure I have taken it from somewhere else) - Jacob ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] [BlueBream] Referring to same interface using zope.schema.Object
On 22 July 2011 13:32, Joshua Immanuel wrote: > Hello, > > On Fri, 2011-07-22 at 13:41 +0200, Jacob Holm wrote: >> On 2011-07-22 13:26, Brian Sutherland wrote: >> > This would be my first guess: >> > >> > class INode(Interface): >> > pass >> > >> > INode.parent = Object( >> > title=u"Parent node", >> > schema=INode >> > ) >> > >> > INode.children = List( >> > title=u'Child nodes', >> > value_type=Object(schema=INode) >> > ) >> > >> > > The method suggested by Brian works without any issues. :) No, there are issues. Take this example: >>> class ITest(Interface): ... title = schema.TextLine() ... >>> ITest.names > >>> ITest.names() ['title'] >>> ITest.description = schema.Text() >>> ITest.names() ['title'] The fields on an interface are not stored as attributes, but are accessible using item access, e.g: ITest['title']. You cannot assign that way though: >>> ITest['description'] = schema.TextLine() Traceback (most recent call last): File "", line 1, in TypeError: 'InterfaceClass' object does not support item assignment Adding to an interface requires messing with the '_InterfaceClass__attrs' attribute of the dictionary and is discouraged. Laurence ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Referring to same interface using zope.schema.Object
On Fri, Jul 22, 2011 at 01:41:32PM +0200, Jacob Holm wrote: > On 2011-07-22 13:26, Brian Sutherland wrote: > > This would be my first guess: > > > > And that guess would be wrong. Thanks. Guess I should stop guessing;) -- Brian Sutherland ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] [BlueBream] Referring to same interface using zope.schema.Object
Hello Laurence, On Fri, 2011-07-22 at 13:57 +0100, Laurence Rowe wrote: > No, there are issues. Take this example: > > >>> class ITest(Interface): > ... title = schema.TextLine() > ... > >>> ITest.names > > > >>> ITest.names() > ['title'] > >>> ITest.description = schema.Text() > >>> ITest.names() > ['title'] > > The fields on an interface are not stored as attributes, but are > accessible using item access, e.g: ITest['title']. You cannot assign > that way though: > > >>> ITest['description'] = schema.TextLine() > Traceback (most recent call last): > File "", line 1, in > TypeError: 'InterfaceClass' object does not support item assignment > > Adding to an interface requires messing with the > '_InterfaceClass__attrs' attribute of the dictionary and is > discouraged. Thanks for enlightening me with this wonderful explanation. As Jacob mentioned, list(INode) in debug shell was very handy to debug. -- Joshua Immanuel HiPro IT Solutions Private Limited http://hipro.co.in signature.asc Description: This is a digitally signed message part ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] [BlueBream] Referring to same interface using zope.schema.Object
Hello Laurence, On Fri, 2011-07-22 at 13:57 +0100, Laurence Rowe wrote: > No, there are issues. Take this example: > > >>> class ITest(Interface): > ... title = schema.TextLine() > ... > >>> ITest.names > > > >>> ITest.names() > ['title'] > >>> ITest.description = schema.Text() > >>> ITest.names() > ['title'] > > The fields on an interface are not stored as attributes, but are > accessible using item access, e.g: ITest['title']. You cannot assign > that way though: > > >>> ITest['description'] = schema.TextLine() > Traceback (most recent call last): > File "", line 1, in > TypeError: 'InterfaceClass' object does not support item assignment > > Adding to an interface requires messing with the > '_InterfaceClass__attrs' attribute of the dictionary and is > discouraged. Thanks for enlightening me with this wonderful explanation. As Jacob mentioned, list(INode) in debug shell was very handy to debug. -- Joshua Immanuel HiPro IT Solutions Private Limited http://hipro.co.in signature.asc Description: This is a digitally signed message part ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Referring to same interface using zope.schema.Object
Hi, On 22.07.2011 12:59, Joe Steeve wrote: Hello, I am trying to construct an object tree. Take a look at http://pypi.python.org/pypi/node This is probably what you need. Regards, Robert Every node in the tree is of the same type. I am trying to achieve something like: class INode(Interface): parent = Object( title=u"Parent node", schema=INode ) children = List( title=u'Child nodes', value_type=Object(schema=INode) ) The above fails with "NameError: name 'INode' is not defined". Any clues as to how to solve this? Regards, Joe ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope ) -- Robert Niederreiter Squarewave Computing Aflingerstraße 19 A-6176 Völs Tel: +43 699 160 20 192 Web: http://www.squarewave.at ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] Referring to same interface using zope.schema.Object
Am 22.07.2011 um 15:30 schrieb Robert Niederreiter: > Hi, > > On 22.07.2011 12:59, Joe Steeve wrote: >> Hello, >> >> I am trying to construct an object tree. >> > Take a look at http://pypi.python.org/pypi/node > This is probably what you need. or even http://pypi.python.org/pypi/zope.container might be enough. Mit freundlichen Grüßen -- Michael Howitz · m...@gocept.com · Softwareentwickler gocept gmbh & co. kg · Forsterstraße 29 · 06112 Halle (Saale) · Deutschland http://gocept.com · Tel +49 345 1229889 8 · Fax +49 345 1229889 1 Zope- und Plone-Beratung und -Entwicklung ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] zope-tests - FAILED: 4, OK: 78
This is the summary for test reports received on the zope-tests list between 2011-07-21 00:00:00 UTC and 2011-07-22 00:00:00 UTC: See the footnotes for test reports of unsuccessful builds. An up-to date view of the builders is also available in our buildbot documentation: http://docs.zope.org/zopetoolkit/process/buildbots.html#the-nightly-builds Reports received Bluebream / Python2.4.6 64bit linux Bluebream / Python2.5.5 64bit linux Bluebream / Python2.6.5 64bit linux ZTK 1.0 / Python2.4.6 Linux 64bit ZTK 1.0 / Python2.5.5 Linux 64bit ZTK 1.0 / Python2.6.5 Linux 64bit [1]ZTK 1.0dev / Python2.4.6 Linux 64bit [2]ZTK 1.0dev / Python2.5.5 Linux 64bit [3]ZTK 1.0dev / Python2.6.5 Linux 64bit Zope 3.4 KGS / Python2.4.6 64bit linux Zope 3.4 KGS / Python2.5.5 64bit linux Zope 3.4 Known Good Set / py2.4-32bit-linux Zope 3.4 Known Good Set / py2.4-64bit-linux Zope 3.4 Known Good Set / py2.5-32bit-linux Zope 3.4 Known Good Set / py2.5-64bit-linux Zope Buildbot / zope2.12-py2.6 slave-osx Zope Buildbot / zope2.12-py2.6 slave-ubuntu32 Zope Buildbot / zope2.13-py2.6 slave-osx Zope Buildbot / zope2.13-py2.6 slave-ubuntu32 Zope Buildbot / zope2.13-py2.7 slave-osx Zope Buildbot / zope2.13-py2.7 slave-ubuntu32 Zope Buildbot / zope2.13_win-py2.6 slave-win Zope Buildbot / zope2.13_win-py2.7 slave-win Zope Buildbot / zope2.14-py2.6 slave-osx Zope Buildbot / zope2.14-py2.6 slave-ubuntu32 Zope Buildbot / zope2.14-py2.7 slave-osx Zope Buildbot / zope2.14-py2.7 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.0-py2.4 slave-osx Zope Buildbot / zopetoolkit-1.0-py2.4 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.0-py2.4 slave-ubuntu64 Zope Buildbot / zopetoolkit-1.0-py2.5 slave-osx Zope Buildbot / zopetoolkit-1.0-py2.5 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.0-py2.5 slave-ubuntu64 Zope Buildbot / zopetoolkit-1.0-py2.6 slave-osx Zope Buildbot / zopetoolkit-1.0-py2.6 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.0-py2.6 slave-ubuntu64 Zope Buildbot / zopetoolkit-1.0_win-py2.4 slave-win Zope Buildbot / zopetoolkit-1.0_win-py2.5 slave-win Zope Buildbot / zopetoolkit-1.0_win-py2.6 slave-win Zope Buildbot / zopetoolkit-1.1-py2.5 slave-osx Zope Buildbot / zopetoolkit-1.1-py2.5 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.1-py2.5 slave-ubuntu64 Zope Buildbot / zopetoolkit-1.1-py2.6 slave-osx Zope Buildbot / zopetoolkit-1.1-py2.6 slave-ubuntu32 Zope Buildbot / zopetoolkit-1.1-py2.6 slave-ubuntu64 Zope Buildbot / zopetoolkit-1.1_win-py2.5 slave-win Zope Buildbot / zopetoolkit-1.1_win-py2.6 slave-win Zope Buildbot / zopetoolkit-py2.5 slave-osx Zope Buildbot / zopetoolkit-py2.5 slave-ubuntu32 Zope Buildbot / zopetoolkit-py2.5 slave-ubuntu64 Zope Buildbot / zopetoolkit-py2.6 slave-osx Zope Buildbot / zopetoolkit-py2.6 slave-ubuntu32 Zope Buildbot / zopetoolkit-py2.6 slave-ubuntu64 Zope Buildbot / zopetoolkit_win-py2.5 slave-win Zope Buildbot / zopetoolkit_win-py2.6 slave-win Zope-2.10 Python-2.4.6 : Linux Zope-2.11 Python-2.4.6 : Linux Zope-2.12 Python-2.6.6 : Linux Zope-2.12-alltests Python-2.6.6 : Linux Zope-2.13 Python-2.6.6 : Linux Zope-2.13-alltests Python-2.6.6 : Linux Zope-trunk Python-2.6.6 : Linux Zope-trunk-alltests Python-2.6.6 : Linux winbot / ZODB_dev py_254_win32 winbot / ZODB_dev py_265_win32 winbot / ZODB_dev py_265_win64 winbot / ZODB_dev py_270_win32 winbot / ZODB_dev py_270_win64 [4]winbot / zope.app.interface_py_265_32 winbot / ztk_10 py_254_win32 winbot / ztk_10 py_265_win32 winbot / ztk_10 py_265_win64 winbot / ztk_11 py_254_win32 winbot / ztk_11 py_265_win32 winbot / ztk_11 py_265_win64 winbot / ztk_11 py_270_win32 winbot / ztk_11 py_270_win64 winbot / ztk_dev py_254_win32 winbot / ztk_dev py_265_win32 winbot / ztk_dev py_265_win64 winbot / ztk_dev py_270_win32 winbot / ztk_dev py_270_win64 Non-OK results -- [1]FAILED ZTK 1.0dev / Python2.4.6 Linux 64bit https://mail.zope.org/pipermail/zope-tests/2011-July/046532.html [2]FAILED ZTK 1.0dev / Python2.5.5 Linux 64bit https://mail.zope.org/pipermail/zope-tests/2011-July/046534.html [3]FAILED ZTK 1.0dev / Python2.6.5 Linux 64bit https://mail.zope.org/pipermail/zope-tests/2011-July/046533.html [4]FAILED winbot / zope.app.interface_py_265_32 https://mail.zope.org/pipermail/zope-tests/2011-July/046551.html ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev *