[Zope] Python Scripts

Chris McDonough chrism@zope.com
Sat, 27 Jul 2002 19:03:50 -0400


Dennis,

This works:

context.manage_addProduct['PythonScripts'].manage_addPythonScript('bar
')

The thing in quotes passed in to manage_addProduct is the *Product
name*.  For the case of Python Scripts, this is 'PythonScripts' (see
your Zope's lib/python/Products directory... you'll see a directory
named PythonScripts.. this is the product name).

The method called manage_addPythonScript is the ZMI constructor for
Python Scripts.  It's defined by way of the PythonScript product's
__init__.py initialize() method.

        constructors=(PythonScript.manage_addPythonScriptForm,
                      PythonScript.manage_addPythonScript),

(the second one is the constructor, the first is the form).  The
actual definition of the constructor "manage_addPythonScript" in this
case is inside lib/python/Products/PythonScripts/PythonScript.py.  You
can see what arguments it takes by looking at this file.

Every ZMI-addable object has a constructor that is defined in a
similar way.  Each constructor is different so it's best to either use
the help system to figure out its arguments or just examine the source
directly.

- C


----- Original Message -----
From: "Dennis Allison" <allison@sumeru.stanford.EDU>
To: <zope@zope.org>
Sent: Saturday, July 27, 2002 6:04 PM
Subject: [Zope] Python Scripts


> I'm trying to create a Script (Python) object on the fly.  I know
> the constructor is manage_addPythonScript and the metatype is
'Script
> (Python)'.  What I can't figure out is the appropriate Dispatcher?
I've
> looked and elsewhere to no avail.  I have tried
manage_addProduct['OFSP'],
> but it's clearly not the right one.  Some other obvious permutations
> also failed.
>
> I've been led to believe that the proper dispatcher for foldershi
items
> is manage_addProduct['OFSP'], but what about for other products?
>
> In the same vein, what is the Dispatcher for ZClasses?
manage_addZClass?
>
>
> _______________________________________________
> 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 )
>