[Re: [Zope] Problem with passing objects from External Methods]
Chris McDonough
chrism@digicool.com
Tue, 10 Apr 2001 20:07:04 -0400
Hi Jason,
Is there a traceback associated with the error? (If it's not
immediately evident, view the page source).
Jason Joy wrote:
>
> Chris,
>
> I thank you for all your help with this frustrating issue. All your changes
> have pointed me in the right direction, but I am facing one other issue with
> it that I was wondering if you could shed some light on.
>
> The <dtml-var foo> within the <dtml-in passthis(bar)> is raising an
> interesting error of:
>
> Error Type: TypeError
> Error Value: call of non-function (type string)
>
> Removing the <dtml-var foo> does not bring up this error, of course. Is there
> something that I am missing?
>
> Jason
>
> Chris McDonough <chrism@digicool.com> wrote:
> Hi Jason,
>
> This is a stumper. But there's a solution. Rewrite your external
> method to look like this:
>
> import string, regex
> from AccessControl import ClassSecurityInfo
> from Acquisition import Implicit
> import Globals
>
> class element(Implicit):
> security = ClassSecurityInfo()
> security.declareObjectPublic()
> security.setDefaultAccess('allow')
>
> def passthis(passed):
> info = []
> structures = string.split(passed)
> for structure in structures:
> bit = element()
> bit.data = foo
> bit.source = structure
> info.append(bit)
> return(info)
>
> Globals.InitializeClass(element)
>
> For more info on why this is necessary, see
> http://dev.zope.org/Wikis/DevSite/Projects/DeclarativeSecurity/ZopeSecurityForDevelopers
>
> HTH,
>
> - C
>
> > def passthis(passed):
> > class element:
> > pass
> > info = []
> > structures = string.split(passed)
> > for structure in structures:
> > bit = element()
> > ## Get Information here, and store it in foo.
> > bit.data = foo
> > bit.source = structure
> > info.append(bit)
> > return(info)
> >
> > ---
>
> Jason Joy wrote:
> >
> > This one has been driving me a bit crazy and I think there is a simple
> > solution to this. I have written an external method to return a list of
> > objects back to a DTML method which executes the code via a dtml-in.
> >
> > The dtml code looks like:
> >
> > <dtml-in processMethod(passthis)>
> > <dtml-var sequence-index><dtml-var data><BR>
> > </dtml-in>
> >
> > And this is passthis.py:
> >
> > import string, regex
> >
> > def passthis(passed):
> > class element:
> > pass
> > info = []
> > structures = string.split(passed)
> > for structure in structures:
> > bit = element()
> > ## Get Information here, and store it in foo.
> > bit.data = foo
> > bit.source = structure
> > info.append(bit)
> > return(info)
> >
> > ---
> >
> > When I run the code, I get a box that asks me to revalidate my Zope login
> and
> > nothing works, finally, the system gives up and gives me an error with this
> at
> > the bottom:
> >
> > File /usr/local/Zope-2.3.0/lib/python/AccessControl/ZopeSecurityPolicy.py,
> > line 168, in validate
> > Unauthorized: data
> >
> > Does anyone have any advice on this one? This is an example of what I am
> > doing and I need to pass a list of objects (with about 10 properties on
> each)
> > to be run through a dtml-in.
> >
> > Thanks,
> >
> > Jason
> >
> > ____________________________________________________________________
> > Get free email and a permanent address at http://www.netaddress.com/?N=1
> >
> > _______________________________________________
> > 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 )
>
> _______________________________________________
> 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 )
>
> ____________________________________________________________________
> Get free email and a permanent address at http://www.netaddress.com/?N=1