[Zope] classes in external methods
Max M
maxm at mxm.dk
Tue Mar 16 17:01:56 EST 2004
nwingfield at dixon-hughes.com wrote:
> Since Zope's Python Scripts will not allow me to import the csv module, I
> wrote my own little class within an External Method. My class opens a CSV
> file and returns a dictionary representation of each line, one at a time.
> Now Zope pops up an authentication dialog when I try to call my External
> Method. Is there some way around this? Can someone also explain why Zope
> does this? I thought an External Methods was a failsafe way to write
> unrestricted Zope code without going all out and writing a product (which
> just doesn't make sense in this instance).
> Nathaniel
It is.
But the object you return is probably not a simple Python data type.
As far as I remember the csv module returns some kind of iterator, (a
Reader object?) not just a list of dictionaries.
Such a class can not be accessed by dtml/zpt. It is protected by the
security machinery.
This means that you either need to set::
obj.__allow_access_to_unprotected_subobjects__=1
On the reader object that is returned.
Or you could convert it to a real list of dictionaries and return that.
Which is the most correct way to do it.
Such simple types are not protected by Zope.
regards Max M
--
hilsen/regards Max M, Denmark
http://www.mxm.dk/
IT's Mad Science
More information about the Zope
mailing list