Jim Fulton wrote:
> 
> Chris Withers wrote:
> >
> > Toby Dickenson wrote:
> > > <http://www.zope.org/Members/htrd/howto/FunctionTemplate>
> > >
> > > you would use....
> > >
> > >     def a_method(self,md):
> > >         do_stuff_with(md['param1'],md['param2'])
> > >     a_method = FunctionTemplate(a_method)
> >
> > That looks like it'll do the trick... I wonder if there's any way you
> > can role it up into a Product so that I don't need to have
> > FunctionTemplate.py in each folder of a product that needs to use it?
> 
> Is it *really* the case that you often want to method to be called directly
> via the Web *and* and from DTML?  This doesn't seem right to me.

As I understand it, that's not the issue.  Chris wants to receive the
DTML namespace implicitly.

> In any case, if you *just* want to get your function to be
> called from DTML (and your class is an extension class), you can give
> it the isDocTemp attribute like so:
> 
>   class MyClass(.... include some extension class ...):
> 
>     some_methodisDocTemp=1
>     def some_method(trueself, self, REQUEST, RESPONSE=None):
>         ....

That's a good idea, I wish I'd thought of it. :-)

However, the new calling convention (__render_with_namespace__, or
something like that) might break "isDocTemp" code.

> Note that if you get called from the web, RESPONSE will
> not be none. This is a handy way to decide if you
> are called from the web or as a sub-template. Of course,
> someone could pass a non-None RESPONSE argument directly.

This convention is helpful but not at all documented, so products (ZWiki
is a good example) often break this convention.

Shane

_______________________________________________
Zope-Dev maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to