Re: [Zope] Help save my sanity (DTML-in string comparison)
Darin Lee writes:
... comparisons involving "id" do not work ... "id" is particularly difficult in DTML.
For some objects, "id" is an attribute (a string), for others, it is a method. Due to Zope's acquisition magic, it is difficult to compare method's to one another: the "same" method compare different, if accessed on different access paths. Thus, you want to work with strings only. The problem is: DTML does not let you test for types. You can do something like this: <dtml-with your_object> <dtml-let id_name=id> <!-- now: "id_name" contains a string --> <dtml-call "REQUEST.set('id_name',id_name)> </dtml-let> </dtml-with> Dieter
On Tue, Dec 19, 2000 at 09:57:31PM +0100, Dieter Maurer wrote:
Darin Lee writes:
... comparisons involving "id" do not work ... "id" is particularly difficult in DTML.
For some objects, "id" is an attribute (a string), for others, it is a method.
Due to Zope's acquisition magic, it is difficult to compare method's to one another: the "same" method compare different, if accessed on different access paths.
Thus, you want to work with strings only. The problem is: DTML does not let you test for types.
You can do something like this:
<dtml-with your_object> <dtml-let id_name=id> <!-- now: "id_name" contains a string --> <dtml-call "REQUEST.set('id_name',id_name)> </dtml-let> </dtml-with>
Or you could use "_['id']" in place of "id". Which does exactly the same as the let tag does in the above statement, ie a lookup in the namespace and then calling it if it is a method. Example: <dtml-with your_object> <dtml-call "REQUEST.set('id_name', _['id'])"> </dtml-with> This kind of hoopjumping is exactly why in Zope 2.3 you now can use the method 'getId()', which will hide the confusion for you. From Zope 2.3 onwards, *always* use getId(): <dtml-with your_object> <dtml-call "REQUEST.set('id_name', getId())"> </dtml-with> or: <dtml-call "REQUEST.set('id_name', your_object.getId())"> -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------
participants (2)
-
Dieter Maurer -
Martijn Pieters