[Zope] calling a DTML Method from a DTML MEthod from a Python PRoduct...

Johan Carlsson johanc at easypublisher.com
Wed Sep 8 04:13:56 EDT 2004


Bill Hewitt wrote:

> Ive got a need to call a DTML Method from a DTML Method I call in a
> Python Product:
> 
> In the Python File, I use to call the Creation Form (a DTML Method):

Note. DTMLFile (HTMLFile have changed name) is not identical to DTML 
Method.

> manage_addCampusForm = HTMLFile('campus_dtml/CampusAddForm',globals())
> 
> manage_addCampusForm needs to call:
> 
> tableSubmitButtons =
> HTMLFile('campus_dtml/tableSubmitButtons',globals())
> 
> Which is in the same directory as "manage_addCampusForm". Where do I put
> the second method above so that the Python Product/first DTML method
> finds it?

If both are defined in the same class they are accessed
from the instance object (self) which is create long after the
class definition is executed. There for the order in which they
are defined doesn't matter :-)

The problem is, if I understand you correctly that you want to add
a second "constructor" method to be used during Product Instantiation?

The Product constructors are usually define at modular level and
added to the Zope Product machinery during Product registation in
the initialize(context) method for that product.

    context.registerClass(
	...
         constructors=(<Module>.manage_addMethodForm,
                       <Module>.manage_addMethod),
                       ...
	...)

You should be able to add extra methods here.

But, you must know where it will appear i Zope to be able to
use it. Accessing the methods fomr easy other they are
in the same context of it would work fine.

Accessing it from outside the Product Add context you
need to look them up in the correct product context, like this: 
manage_addProduct['<product name>'].<method name>

Regards,
Johan Carlsson

-- 
Johan Carlsson          Tel: + 46 8 31 24 94
Colliberty              Mob: + 46 70 558 25 24
Torsgatan 72            Email: johanc at easypublisher.com
SE-113 37 STOCKHOLM


More information about the Zope mailing list