Re: [Zope-dev] context bindings in python products
i got it finally - jo def test(self,REQUEST=None): """ test """ context = REQUEST.PARENTS[0] return context.absolute_url() the reason why: in another project i used a python script which returns a specific property: if the property in the current object has some specific value, lets say "--" then the property is looked up in the parent object (recursively) till it comes to a special "root" object. i use this to let users choose if they want to inherit the property from the parent object - this is good for meta-tags in html note that i dont want to let users delete/create properties, and zope only aquires the property from the parent if its not there. now i want to include this function into my python product so e needed a context object its not implementet till now, but i think it works with the function above cu bernd - Original Message - From: "Toby Dickenson" <[EMAIL PROTECTED]> To: "Chris McDonough" <[EMAIL PROTECTED]> Cc: "Bernd Dorn" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Wednesday, June 06, 2001 12:15 PM Subject: Re: [Zope-dev] context bindings in python products On Tue, 05 Jun 2001 15:56:45 -0400, Chris McDonough <[EMAIL PROTECTED]> wrote: >context = self >container = self.aq_inner.aq_parent No amount of aquisition trickery will give a method access to the dtml context, which I *think* is what was asked for. >> the only thing i found was this: >> http://www.zope.org/Members/htrd/howto/FunctionTemplate >> but it seems very complicated in argument passing Like DTMLMethods, all arguments get passed in the 'context'. >> am i the only one who needs this, or is it a sign for wrong coding practice >> in zope? Context-based programming is usually wrong, but not always. If you explain what you are trying to achieve then we may be able to point out a better alternative. (some early drafts of the Zope book encouraged context-based programing in scenarious where it was quite dangerous; Im not sure if this is currently true) Toby Dickenson [EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
On Tue, 05 Jun 2001 15:56:45 -0400, Chris McDonough <[EMAIL PROTECTED]> wrote: >context = self >container = self.aq_inner.aq_parent No amount of aquisition trickery will give a method access to the dtml context, which I *think* is what was asked for. >> the only thing i found was this: >> http://www.zope.org/Members/htrd/howto/FunctionTemplate >> but it seems very complicated in argument passing Like DTMLMethods, all arguments get passed in the 'context'. >> am i the only one who needs this, or is it a sign for wrong coding practice >> in zope? Context-based programming is usually wrong, but not always. If you explain what you are trying to achieve then we may be able to point out a better alternative. (some early drafts of the Zope book encouraged context-based programing in scenarious where it was quite dangerous; Im not sure if this is currently true) Toby Dickenson [EMAIL PROTECTED] ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
either way - thx maybe such a bindings implementation is worth a proposal sometime ... - Original Message - From: "Chris McDonough" <[EMAIL PROTECTED]> To: "Bernd Dorn" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 05, 2001 11:18 PM Subject: Re: [Zope-dev] context bindings in python products > Bernd Dorn wrote: > > > > this doesnt work either > > > > my test funtion: > > > > def test_htm(self): > > """ just test """ > > context = self.aq_parent > > return context.absolute_url() > > > > returns always the absolute_url of the parent object of the class instance > > I think I understand what you mean. > > Yes, you're right. To make it work differently, you're right in saying > you need to create an HTMLFile instance (or another methodish thing). > > - C > > ___ > Zope-Dev maillist - [EMAIL PROTECTED] > http://lists.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > http://lists.zope.org/mailman/listinfo/zope-announce > http://lists.zope.org/mailman/listinfo/zope ) > ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
Bernd Dorn wrote: > > this doesnt work either > > my test funtion: > > def test_htm(self): > """ just test """ > context = self.aq_parent > return context.absolute_url() > > returns always the absolute_url of the parent object of the class instance I think I understand what you mean. Yes, you're right. To make it work differently, you're right in saying you need to create an HTMLFile instance (or another methodish thing). - C ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
this doesnt work either my test funtion: def test_htm(self): """ just test """ context = self.aq_parent return context.absolute_url() returns always the absolute_url of the parent object of the class instance is there something wrong with my product?? it inherits from ofs.folder i think i have to write context aware stuff in HTMLFile objects ? :-( - Original Message - From: "Chris McDonough" <[EMAIL PROTECTED]> To: "Bernd Dorn" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 05, 2001 10:20 PM Subject: Re: [Zope-dev] context bindings in python products > Oops, sorry... roughly, > > context = self.aq_parent > container = self.aq_inner.aq_parent > > Bernd Dorn wrote: > > > > thx, but i tried this already > > > > self always returns the instance of the class in which the method is > > defined, instead of the container/object from which it is called > > > > example: > > two classes, > > class x with method example(): return self > > class y with no method and is a subobject of x > > > > http://www.foo.bar/xInstance/yInstance/method > > returns xInstance instead of yInstance > > ??? > > > > - Original Message - > > From: "Chris McDonough" <[EMAIL PROTECTED]> > > To: "Bernd Dorn" <[EMAIL PROTECTED]> > > Cc: <[EMAIL PROTECTED]> > > Sent: Tuesday, June 05, 2001 9:56 PM > > Subject: Re: [Zope-dev] context bindings in python products > > > > > context = self > > > container = self.aq_inner.aq_parent > > > > > > Bernd Dorn wrote: > > > > > > > > hi > > > > > > > > isn't there some mixin class to provide bindings to python products like > > in > > > > python scripts? > > > > so that i have some objects like: context, container ... > > > > > > > > i searched through the zope site, but there is nothing which can do such > > > > stuff > > > > > > > > am i the only one who needs this, or is it a sign for wrong coding > > practice > > > > in zope? > > > > > > > > the only thing i found was this: > > > > http://www.zope.org/Members/htrd/howto/FunctionTemplate > > > > but it seems very complicated in argument passing > > > > > > > > wouldn't it be nice to have something like this > > > > > > > > if there is nothing out there, has anybody some sugestions how to > > implement > > > > it > > > > so i would write it by myself > > > > > > > > maybe with the REQUEST Class or so? > > > > > > > > thanks in advance, bernd > > > > > > > > ___ > > > > Zope-Dev maillist - [EMAIL PROTECTED] > > > > http://lists.zope.org/mailman/listinfo/zope-dev > > > > ** No cross posts or HTML encoding! ** > > > > (Related lists - > > > > http://lists.zope.org/mailman/listinfo/zope-announce > > > > http://lists.zope.org/mailman/listinfo/zope ) > > > > > > > ___ > > Zope-Dev maillist - [EMAIL PROTECTED] > > http://lists.zope.org/mailman/listinfo/zope-dev > > ** No cross posts or HTML encoding! ** > > (Related lists - > > http://lists.zope.org/mailman/listinfo/zope-announce > > http://lists.zope.org/mailman/listinfo/zope ) > ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
Oops, sorry... roughly, context = self.aq_parent container = self.aq_inner.aq_parent Bernd Dorn wrote: > > thx, but i tried this already > > self always returns the instance of the class in which the method is > defined, instead of the container/object from which it is called > > example: > two classes, > class x with method example(): return self > class y with no method and is a subobject of x > > http://www.foo.bar/xInstance/yInstance/method > returns xInstance instead of yInstance > ??? > > - Original Message - > From: "Chris McDonough" <[EMAIL PROTECTED]> > To: "Bernd Dorn" <[EMAIL PROTECTED]> > Cc: <[EMAIL PROTECTED]> > Sent: Tuesday, June 05, 2001 9:56 PM > Subject: Re: [Zope-dev] context bindings in python products > > > context = self > > container = self.aq_inner.aq_parent > > > > Bernd Dorn wrote: > > > > > > hi > > > > > > isn't there some mixin class to provide bindings to python products like > in > > > python scripts? > > > so that i have some objects like: context, container ... > > > > > > i searched through the zope site, but there is nothing which can do such > > > stuff > > > > > > am i the only one who needs this, or is it a sign for wrong coding > practice > > > in zope? > > > > > > the only thing i found was this: > > > http://www.zope.org/Members/htrd/howto/FunctionTemplate > > > but it seems very complicated in argument passing > > > > > > wouldn't it be nice to have something like this > > > > > > if there is nothing out there, has anybody some sugestions how to > implement > > > it > > > so i would write it by myself > > > > > > maybe with the REQUEST Class or so? > > > > > > thanks in advance, bernd > > > > > > ___ > > > Zope-Dev maillist - [EMAIL PROTECTED] > > > http://lists.zope.org/mailman/listinfo/zope-dev > > > ** No cross posts or HTML encoding! ** > > > (Related lists - > > > http://lists.zope.org/mailman/listinfo/zope-announce > > > http://lists.zope.org/mailman/listinfo/zope ) > > > > ___ > Zope-Dev maillist - [EMAIL PROTECTED] > http://lists.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > http://lists.zope.org/mailman/listinfo/zope-announce > http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
thx, but i tried this already self always returns the instance of the class in which the method is defined, instead of the container/object from which it is called example: two classes, class x with method example(): return self class y with no method and is a subobject of x http://www.foo.bar/xInstance/yInstance/method returns xInstance instead of yInstance ??? - Original Message - From: "Chris McDonough" <[EMAIL PROTECTED]> To: "Bernd Dorn" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 05, 2001 9:56 PM Subject: Re: [Zope-dev] context bindings in python products > context = self > container = self.aq_inner.aq_parent > > Bernd Dorn wrote: > > > > hi > > > > isn't there some mixin class to provide bindings to python products like in > > python scripts? > > so that i have some objects like: context, container ... > > > > i searched through the zope site, but there is nothing which can do such > > stuff > > > > am i the only one who needs this, or is it a sign for wrong coding practice > > in zope? > > > > the only thing i found was this: > > http://www.zope.org/Members/htrd/howto/FunctionTemplate > > but it seems very complicated in argument passing > > > > wouldn't it be nice to have something like this > > > > if there is nothing out there, has anybody some sugestions how to implement > > it > > so i would write it by myself > > > > maybe with the REQUEST Class or so? > > > > thanks in advance, bernd > > > > ___ > > Zope-Dev maillist - [EMAIL PROTECTED] > > http://lists.zope.org/mailman/listinfo/zope-dev > > ** No cross posts or HTML encoding! ** > > (Related lists - > > http://lists.zope.org/mailman/listinfo/zope-announce > > http://lists.zope.org/mailman/listinfo/zope ) > ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] context bindings in python products
context = self container = self.aq_inner.aq_parent Bernd Dorn wrote: > > hi > > isn't there some mixin class to provide bindings to python products like in > python scripts? > so that i have some objects like: context, container ... > > i searched through the zope site, but there is nothing which can do such > stuff > > am i the only one who needs this, or is it a sign for wrong coding practice > in zope? > > the only thing i found was this: > http://www.zope.org/Members/htrd/howto/FunctionTemplate > but it seems very complicated in argument passing > > wouldn't it be nice to have something like this > > if there is nothing out there, has anybody some sugestions how to implement > it > so i would write it by myself > > maybe with the REQUEST Class or so? > > thanks in advance, bernd > > ___ > Zope-Dev maillist - [EMAIL PROTECTED] > http://lists.zope.org/mailman/listinfo/zope-dev > ** No cross posts or HTML encoding! ** > (Related lists - > http://lists.zope.org/mailman/listinfo/zope-announce > http://lists.zope.org/mailman/listinfo/zope ) ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
[Zope-dev] context bindings in python products
hi isn't there some mixin class to provide bindings to python products like in python scripts? so that i have some objects like: context, container ... i searched through the zope site, but there is nothing which can do such stuff am i the only one who needs this, or is it a sign for wrong coding practice in zope? the only thing i found was this: http://www.zope.org/Members/htrd/howto/FunctionTemplate but it seems very complicated in argument passing wouldn't it be nice to have something like this if there is nothing out there, has anybody some sugestions how to implement it so i would write it by myself maybe with the REQUEST Class or so? thanks in advance, bernd ___ Zope-Dev maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )