[Zope] external methods, returning objects...argh!
Gerrie Roos
gerrie@trispen.com
Tue, 05 Jun 2001 16:32:56 +0200
This is the setup:
**childLookup (python method):**
branches = context.childBranchesLookup(BranchParent = parentBranch)
tags = context.childTagsLookup(BranchName = parentBranch)
#these above are ZSQL results...
result = context.createNodeObj(branchResult = branches, tagResult =
tags)
return result
**createNodeObj (external method, calling createNodeObj):**
class _dummy:
def __init__(self, name):
self.name=name
def createNodeObj(branchResult, tagResult):
c = []
for branch in branchResult.dictionaries():
c.append(_dummy(branch["BranchName"]))
for tag in tagResult.dictionaries():
c.append(_dummy(tag["CVSTagNo"]))
return c
So the idea is to call childLookup, which passes ZSQL results on to
createNodeObj, and createNodeObj generates a list of objects and returns
it. I know, I know I could've done it with an external method only...I
only learnt that too late. Now I can't work with the resulting list of
objects in Zope!
for instance:
<dtml-in expr="childLookup(parentBranch = 'Main')">
<dtml-var name>
</dtml-in>
results in:
'Authorization failed. Retry? ' popup in my browser. Then cancelling I
get the following trace:
Zope Error
Zope has encountered an error while publishing this resource.
Unauthorized
Sorry, a Zope error occurred.
Traceback (innermost last):
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/ZPublisher/Publish.py, line
222, in publish_module
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/ZPublisher/Publish.py, line
187, in publish
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/ZPublisher/Publish.py, line
171, in publish
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/ZPublisher/mapply.py, line
160, in mapply
(Object: test_index_html)
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/ZPublisher/Publish.py, line
112, in call_object
(Object: test_index_html)
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/OFS/DTMLDocument.py, line
189, in __call__
(Object: test_index_html)
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_String.py,
line 538, in __call__
(Object: test_index_html)
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/DocumentTemplate/DT_In.py,
line 711, in renderwob
(Object: childLookup(parentBranch = 'Main'))
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/OFS/DTMLMethod.py, line
261, in validate
(Object: test_index_html)
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/AccessControl/SecurityManager.py,
line 144, in validate
File
/usr2/GnatsPkg/src/Zope-2.3.0-src/lib/python/AccessControl/ZopeSecurityPolicy.py,
line 168, in validate
Unauthorized: name
So can't I return a list of objects from an external method?
How will one then get the example of dtml-tree with external methods
shown in
http://www.zope.org/Members/anthony/tree-coding-tricks
to work?
Thanks!