[zope] python scripts

hans hans@beehive.de
Thu, 02 May 2002 11:28:18 +0100


"Jorge O. Martinez" wrote:

> Hi:
>
>  > 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
>
> The above is what I'd like to do; however, could anybody suggest some
> code or a product to look them up? Sorry for the  basic question, but
> still getting to know python and Zope ;-)
>
> I mean something similar to what <dtml-var REQUEST> does for request
> (shows cookies, paths, etc.).

context.REQUEST ?

> Or if possible I'd like to find a way to learn what methods (sorry if
> this is not the right term) are available for a given object (let's say
> for a 'Folder' or a DTML document. Is there a howto. I have taken a look
> at the apendices, but I am still not sure I quite get it.

Folder, hmm
http://www.zope.org/Documentation/ZopeBook/AppendixB.stx
class Folder
(also look at <zoperoot>/lib/python/OFS/Folder.py)
but you can't do anything except adding a folder.
however, the code for folder shows it is (among others)
derived from OjectManager. AppendixB class ObjectManager
(and the sourcecode also) contains a lot of useful methods
like objectItems( [list of] string ) where the string denotes the
wanted meta_type, like so (from the top of my head)
objectItems( ['DTMLDocument'] )
this gets you a list of tuples (id, obj) of DTML Documents contained in the folder.

>
> hans wrote:
> > "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 =)

never bothered abt CMF. however, REQUEST most probably contains
AUTHENTICATED_USER (if cookie-based auth)

>
> > 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.

--
-------------------------------------------------------------
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