Hi I want to acquire an persistent zope object (supplier) that is inside my productfolder myproductfolder/supplier How to get a reference to this object? Also, Is there a method to get the product root? I would like to have that all instances of my class can be traversed like prinstance/suppliers The class has to be derived from SimpleItem. What do I have to add to get it work? class PurchaseRequisition( SimpleItem, Implicit ): suppliers = aq_inner(self).aq_acquire(reference_to_container) Dennis
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 - --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz <d.schulz81@gmx.net> wrote:
Hi
I want to acquire an persistent zope object (supplier) that is inside my productfolder
myproductfolder/supplier
How to get a reference to this object? Also, Is there a method to get the product root?
context.myproductfolder.supplier? That's basic acquisition and should be documented in the Zope Book: <http://www.plope.com/Books/2_7Edition/Acquisition.stx> - -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin) iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66 BUalSLllgOaxmn4C0kBiCns= =E1/0 -----END PGP SIGNATURE-----
I found no example how to define it in the class generally for all instances i would like to access the supplier container under a different name inside one instance of Purchase Requisition. class PurchaseRequisition( SimpleItem, Implicit ): suppliers = property ( lambda self: str( self.context.aq_inner.aq_parent.supplier) ) Andreas Jung escribió:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
- --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz <d.schulz81@gmx.net> wrote:
Hi
I want to acquire an persistent zope object (supplier) that is inside my productfolder
myproductfolder/supplier
How to get a reference to this object? Also, Is there a method to get the product root?
context.myproductfolder.supplier?
That's basic acquisition and should be documented in the Zope Book:
<http://www.plope.com/Books/2_7Edition/Acquisition.stx>
- -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin)
iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66 BUalSLllgOaxmn4C0kBiCns= =E1/0 -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 - --On 13. Dezember 2006 19:56:40 +0100 Dennis Schulz <d.schulz81@gmx.net> wrote:
I found no example how to define it in the class generally for all instances
i would like to access the supplier container under a different name inside one instance of Purchase Requisition.
class PurchaseRequisition( SimpleItem, Implicit ):
suppliers = property ( lambda self: str( self.context.aq_inner.aq_parent.supplier) )
No idea what this (nonsense) code should do. Follow the standard road and write a method def getSuppliers(self): return self.foo.bar.supplier or use self.restrictedTraverse(path) if you are working with path information. - -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin) iD8DBQFFgFVOCJIWIbr9KYwRAsSEAKDiitYhxB+/rcE/L/+Cw2f4reJmKwCfZljA pBe8OXA5jWK9w7waXXC2V+o= =zZf0 -----END PGP SIGNATURE-----
Dennis Schulz wrote:
I found no example how to define it in the class generally for all instances
i would like to access the supplier container under a different name inside one instance of Purchase Requisition.
class PurchaseRequisition( SimpleItem, Implicit ):
suppliers = property ( lambda self: str( self.context.aq_inner.aq_parent.supplier) )
Keep it simple like Andreas suggested:: from Acquisition import aq_inner, aq_parent class PurchaseRequisition( SimpleItem, Implicit ): def suppliers(self): parent = aq_parent(aq_inner(self)) return parent.supplier # does exactly the same thing thanks to automatic # acquisition: def suppliers(self): return self.supplier
Andreas Jung escribió:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
- --On 13. Dezember 2006 19:12:13 +0100 Dennis Schulz <d.schulz81@gmx.net> wrote:
Hi
I want to acquire an persistent zope object (supplier) that is inside my productfolder
myproductfolder/supplier
How to get a reference to this object? Also, Is there a method to get the product root?
context.myproductfolder.supplier?
That's basic acquisition and should be documented in the Zope Book:
<http://www.plope.com/Books/2_7Edition/Acquisition.stx>
- -aj -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (Darwin)
iD8DBQFFgEOjCJIWIbr9KYwRAs/LAJ9ROWS1ArpGH/Mf5+7CesUjXRdGTwCg6U66 BUalSLllgOaxmn4C0kBiCns= =E1/0 -----END PGP SIGNATURE-----
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
-- Peter Bengtsson, work www.fry-it.com home www.peterbe.com hobby www.issuetrackerproduct.com
participants (3)
-
Andreas Jung -
Dennis Schulz -
Peter Bengtsson