[Zope] Getting at third-party modules in dtml?

Paul Winkler pw_lists at slinkp.com
Mon Sep 19 14:46:24 EDT 2005


I've got an ancient DTMLFile UI that I need to add a feature to,
and I really don't want to have to rewrite it all in ZPT today...
I'd love to, just don't have time now...
and there's something I just can't figure out:

Say I have a function that I want to make callable in
my UI. It needs to be globally available, i.e. it needs to
be callable *without* having an instance of my product yet.
(This has to do with listing information about all acquirable
instances of the product, so the user can choose from those
available.)

I can make the security declarations fine, e.g.

ModuleSecurityInfo('Products.MyProduct.utils').declarePublic('getBaz')

.... and then I can import and use getBaz() in python Scripts,
and I can use it in ZPT too by doing something like
python:modules['Products.MyProduct.utils'].doBaz()
.... but how the heck do I do that in DTML?  There's no "modules"
namespace in DTML anywhere that I can find...

I guess I could wrap the function in an external method. But
since this UI is for a product I maintain, I REALLY do not want to have
to add goofy stuff like that to the installation instructions and make
my users clutter their ZODB with external methods. That's way too
fragile and messy.

Thanks,

PW




More information about the Zope mailing list