I am answering my own question so the next person who bumps into it might have more luck tracking it down. The following examples are taken from the 'Security' chapter of the Zope Developers Guidde (ZDG). Note that I still wish there were a way to use external objects unchanged. Particularly because I have a class heirarchy, where customer objects create campaignh objects, but I want to to return campaign objects that have zope security info, so I have to create instances of my zopified objects from the non-zope objects...very wasteful and slow. --sam # an external method that returns Book instances from AccessControl import ClassSecurityInfo from Acquistion import Implicit import Globals class Book(Implicit): def __init__(self, title): self._title=title # Create a SecurityInfo for this class security = ClassSecurityInfo() security.declareObjectPublic() security.declarePublic('getTitle') def getTitle(self): return self._title Globals.InitializeClass(Book) # The actual external method def GetBooks(self): books=[] books.append(Book('King Lear').__of__(self)) books.append(Book('Romeo and Juliet').__of__(self)) books.append(Book('The Tempest').__of__(self)) return books Or, if you can't modify the original object, try this: # an external method that returns Book instances from AccessControl import ClassSecurityInfo from Acquisition import Implicit import bookstuff import Globals class Book(Implicit, bookstuff.Book): security = ClassSecurityInfo() security.declareObjectPublic() security.declarePublic('getTitle') Globals.InitializeClass(Book) # The actual external method def GetBooks(self): books=[] books.append(Book('King Lear')) books.append(Book('Romeo and Juliet')) books.append(Book('The Tempest')) return books On Apr 27, 2004, at 6:26 PM, Sam Gendler wrote:
I used to be a fairly knowledgable zope user many years ago, but things have moved on and I've forgotten most of what I know. I have a largish library of python modules which define a number of classes which have methods that perform work in a product. Currently, much of the system is managed vai commandline tools which utilize the library. We want to ad a web interface, and I figured zope would be a natural, since everything is already in python.
I created external methods which return instances of classes, but if I try to use those instances from within dtml (iterating over a list of them, for instance), I just get prompted for authentication credentials. I seem to recall that there was some way of applying zopishness to external object instances at runtime, but I can't remember what that mechanism is, and I couldn't find it in either the zope book or the zope bible I went out an bought.
For example, if I have a customer class which has name, id, and revenue members, and I create an external method to return a list of customer instances, I cannot do the following
<dtml-in extListCustomers prefix="cust"> <dtml-var expr="cust_item.id"> <dtml-var expr="cust_item.name"> <dtml var expr="cust_item.revenue"> </dtml-in>
Thanks
--sam
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )