Hi, I'm trying to do a tree walk and copy with: <dtml-in objectValues> <dtml-call "REQUEST['where'][-1].manage_addFolder(id)"> Created <dtml-var id> in <dtml-var "REQUEST['where'][-1].id"><BR> <dtml-if "meta_type=='Folder'"> <dtml-call "REQUEST['where'].append(this())"> <dtml-var iterate> <dtml-call "REQUEST['where'].pop()"> ...etc... but I get the following truly horrible error from the manage_addFolder any ideas? Chris Error Type: TypeError Error Value: read-only character buffer, Python Method Traceback (innermost last): File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 214, in publish_module File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 179, in publish File /usr/local/zope/2-1-6/lib/python/Zope/__init__.py, line 202, in zpublisher_exception_hook (Object: ElementWithAttributes) File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 165, in publish File /usr/local/zope/2-1-6/lib/python/ZPublisher/mapply.py, line 160, in mapply (Object: start) File /usr/local/zope/2-1-6/lib/python/ZPublisher/Publish.py, line 102, in call_object (Object: start) File /usr/local/zope/2-1-6/lib/python/OFS/DTMLMethod.py, line 150, in __call__ (Object: start) File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: start) File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_With.py, line 148, in render (Object: o-e-s) File /usr/local/zope/2-1-6/lib/python/OFS/DTMLMethod.py, line 146, in __call__ (Object: iterate) File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_String.py, line 502, in __call__ (Object: iterate) File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_In.py, line 691, in renderwob (Object: objectValues) File /usr/local/zope/2-1-6/lib/python/DocumentTemplate/DT_Util.py, line 335, in eval (Object: REQUEST['where'][-1].manage_addFolder(id)) (Info: REQUEST) File <string>, line 0, in ? File /usr/local/zope/2-1-6/lib/python/OFS/Folder.py, line 119, in manage_addFolder (Object: ElementWithAttributes) File /usr/local/zope/2-1-6/lib/python/OFS/ObjectManager.py, line 231, in _setObject (Object: ElementWithAttributes) File /usr/local/zope/2-1-6/lib/python/OFS/ObjectManager.py, line 200, in _checkId (Object: ElementWithAttributes) File /usr/local/zope/2-1-6/lib/python/ts_regex.py, line 139, in match TypeError: (see above)
Found the problem, now what's the solution: Chris Withers wrote:
<dtml-in objectValues> <dtml-call "REQUEST['where'][-1].manage_addFolder(id)">
<dtml-var "id"> in this context returns a Python Method object. WHY?! ;-) In a more constructive tone, how can I get the string id from this? cheers, Chris
From: Chris Withers <chrisw@nipltd.com>
<dtml-call "REQUEST['where'][-1].manage_addFolder(id)">
Error Type: TypeError Error Value: read-only character buffer, Python Method
Looks like the 'id' of something along the line is a method rather than a string. Try "_.getitem('id', 1)". Cheers, Evan @ digicool & 4-am
Evan, Thanks, that worked... Evan Simpson wrote:
From: Chris Withers <chrisw@nipltd.com>
<dtml-call "REQUEST['where'][-1].manage_addFolder(id)">
Error Type: TypeError Error Value: read-only character buffer, Python Method
Looks like the 'id' of something along the line is a method rather than a string. Try "_.getitem('id', 1)".
I thought I'd seen it all when it came to Zope being bad, but this is TRULY horrible, it even beats (_,_.None,...) and I thought that would never happen... Can someone please tell me why folder.id is a method and everything-else.id is a string? Should I chuck this in the collector? (I think I will anyway! :P) Excuse me while I go off to be sick ;-) Chris
Chris Withers wrote:
Chris Withers wrote:
Can someone please tell me why folder.id is a method and everything-else.id is a string?
Sorry, that should be folder.id is a string and everything-else.id is a method.
Interesting commentary from the Interfaces Wiki: http://www.zope.org/Members/michel/Projects/Interfaces/ObjectManagerItem """Some old objects provide id methods that return ids. This practice should be avoided for new objects. We can't change the old objects for backward compatability reasons. Maybe we should fix this in Zope 3.0.""" -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
participants (3)
-
Chris Withers -
Evan Simpson -
Steve Alexander