[zope] python scripts

hans hans@beehive.de
Mon, 29 Apr 2002 14:06:01 +0100


"Ian!" wrote:

> I am having a very hard time writing python scripts for zope. I don't know
> which objects do what, and I can't find out where to look up the relevant
> documentation.
>
> I brought this up in an earlier post to the list, but I didn't get a
> response. I've read through the zope book (at
> http://www.zope.org/Documentation/ZopeBook/contents ), but it doesn't really
> cover what I'm looking for - it doesn't really seem to be a guide to writing
> scripts.
>
> The Zope API reference seems to be the reference for people who are
> developing products or external methods for zope, because all of those
> modules can't imported from within a python script under zope, even though
> it seems like stuff I would want to use.
> http://www.zope.org/Documentation/ZopeBook/AppendixB.stx
>
> The Zope help from within the zope management interface contains the same
> API reference, as well as some other stuff that (as far as I can tell) isn't
> what I'm looking for.
>
> I want to get the current CMF member and change some of it's extra data
> attributes (attributes which I added with the management interface
> portal_memberdata) - I don't know how to do this, but more importantly I
> don't know where to look up how to do it. Can anyone help me out? Sorry for
> being such a lost newbie =)

Names (and their ojects) may be looked up
from the names/attributes of the default bound objects (at least, zope 2.5.0):
context, container, script, traverse_subpath

when your script is called, these are defined.
context is the caller (usually some zpt/dtml-document),
container the containing folder

as these objects are objects in data.fs,
data.fs is an object collection organized as a tree
(ObjectManager is one of the base classes of Folder),
close to any object (and its attributes) are accessible from your py script
(security aside).
execution pereforms in a restricted environment,
the zope book dtml-appendix contains a list of restricted code.

hth for a start
--
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin  (software developer)           hans@beehive.de
beehive elektronische medien GmbH       http://www.beehive.de
phone: +49 30 847-82 0                  fax: +49 30 847-82 299