[Zope] external methods, returning objects...argh!

Gerrie Roos gerrie@trispen.com
Wed, 06 Jun 2001 09:18:06 +0200


Yes, I have.  I suppose you talk about the dtml document calling
<dtml-in expr="childLookup(parentBranch = 'Main')">

It makes no difference.  I'm doing all testing as a manager.

It seems I have to return an object of a type Zope already knows, something like
Results objects returned by ZSQLMethods...but to be honest, I haven't completely
figured out how to create my own Results object and it seems a bit of a roundabout way
of doing it...

andres@corrada.com wrote:

> So, have you tried proxying the dtml object as manager to see if the
> authorization problem goes away?
>
> On Tue, Jun 05, 2001 at 04:32:56PM +0200, Gerrie Roos wrote:
> > 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!
> >
> >
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists -
> >  http://lists.zope.org/mailman/listinfo/zope-announce
> >  http://lists.zope.org/mailman/listinfo/zope-dev )
> >
>
> --
> ------------------------------------------------------
> Andres Corrada-Emmanuel   Email: andres@corrada.com
> Internet Programming      http://www.mamey.com
> ------------------------------------------------------