expected string or Unicode object, ImplicitAcquirerWrapper found
I must be missing something... help! I have a python script called logoName.py, as follows: return 'logo.jpg' then I'm trying to use that in a DTML method. This works fine: &dtml-portal_url;/&dtml-logoName; Whereas this gives me an error: <dtml-var "_[logoName].getURL"> the error traceback being: ------------------- Exception Type TypeError Exception Value expected string or Unicode object, ImplicitAcquirerWrapper found Traceback (innermost last): * Module ZPublisher.Publish, line 98, in publish * Module ZPublisher.mapply, line 88, in mapply * Module ZPublisher.Publish, line 39, in call_object * Module Products.CMFCore.FSDTMLMethod, line 141, in __call__ * Module DocumentTemplate.DT_String, line 474, in __call__ * Module DocumentTemplate.DT_With, line 76, in render * Module DocumentTemplate.DT_Util, line 201, in eval __traceback_info__: logoName * Module <string>, line 2, in f * Module AccessControl.DTML, line 32, in guarded_getitem * Module AccessControl.ZopeGuards, line 90, in guarded_getitem TypeError: expected string or Unicode object, ImplicitAcquirerWrapper found ------------------- I really need to use the latter construct, is it possible to change my python script to give it the right thing? M
Marc Lindahl wrote:
then I'm trying to use that in a DTML method. This works fine:
&dtml-portal_url;/&dtml-logoName;
Whereas this gives me an error:
<dtml-var "_[logoName].getURL">
You liekly wouldn't have this mess if you wer eusing ZPT. try: <dtml-var "_[logoName].getURL()"> Failing that: <dtml-var "_[logoName()].getURL()"> failing that, try: <dtml-var "_.getItem(logoName).getURL()"> after that, find out what logoName really is ;-) Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Marc Lindahl wrote at 2004-3-22 12:57 -0500:
I have a python script called logoName.py, as follows:
return 'logo.jpg'
then I'm trying to use that in a DTML method. This works fine:
&dtml-portal_url;/&dtml-logoName;
Whereas this gives me an error:
<dtml-var "_[logoName].getURL"> ... __traceback_info__: logoName * Module <string>, line 2, in f * Module AccessControl.DTML, line 32, in guarded_getitem * Module AccessControl.ZopeGuards, line 90, in guarded_getitem
TypeError: expected string or Unicode object, ImplicitAcquirerWrapper found
"logoName" is an "ImplicitAcquirerWrapper" wrapping your Python Script. Thus, you should call it to get "logo.jpg". I expect that you somehow want to get the object with id "logo.jpg". This would look like: "_.getitem(logoName())". I do not know "getURL". The name suggests it is a method, then "_.getitem(logoName()).getURL" would be wrong. Instead, you would need to use "_.getitem(logoName()).getURL()". However, I expect, "getURL" is not the correct method... -- Dieter
On Tuesday, March 23, 2004, at 03:25 PM, Dieter Maurer wrote:
Marc Lindahl wrote at 2004-3-22 12:57 -0500:
I have a python script called logoName.py, as follows:
return 'logo.jpg'
then I'm trying to use that in a DTML method. This works fine:
&dtml-portal_url;/&dtml-logoName;
Whereas this gives me an error:
<dtml-var "_[logoName].getURL"> ... __traceback_info__: logoName * Module <string>, line 2, in f * Module AccessControl.DTML, line 32, in guarded_getitem * Module AccessControl.ZopeGuards, line 90, in guarded_getitem
TypeError: expected string or Unicode object, ImplicitAcquirerWrapper found
"logoName" is an "ImplicitAcquirerWrapper" wrapping your Python Script. Thus, you should call it to get "logo.jpg".
I expect that you somehow want to get the object with id "logo.jpg". This would look like:
"_.getitem(logoName())".
got it... that works... also looks like no way to get something that behaves like a variable or property but is really a python script returning something :(
I do not know "getURL". The name suggests it is a method, then "_.getitem(logoName()).getURL" would be wrong. Instead, you would need to use "_.getitem(logoName()).getURL()". However, I expect, "getURL" is not the correct method...
yes, it's the wrong one - it's for catalogs. I meant absolute_url(). Anyway....
Marc Lindahl wrote:
"logoName" is an "ImplicitAcquirerWrapper" wrapping your Python Script. Thus, you should call it to get "logo.jpg".
I expect that you somehow want to get the object with id "logo.jpg". This would look like:
"_.getitem(logoName())".
got it... that works... also looks like no way to get something that behaves like a variable or property but is really a python script returning something :(
<tal:x define="logoName here/logoName"> ...works for me ;-) Chris PS: If you insist on torturing yourself, you can use dtml-let in the same way... -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk
Marc Lindahl wrote at 2004-3-23 21:21 -0500:
...
I expect that you somehow want to get the object with id "logo.jpg". This would look like:
"_.getitem(logoName())".
got it... that works... also looks like no way to get something that behaves like a variable or property but is really a python script returning something :(
You can use DTML magic to blur the difference between a variable and a Python Script: "_.getitem(_['logoName'])" or <dtml-let logoName=logoName> ...logoName ... </dtml-let> -- Dieter
participants (3)
-
Chris Withers -
Dieter Maurer -
Marc Lindahl