RFE: Make PythonScripts.standard available from DTML _.standard
This is an RFE for Zope 2.3. I'm posting it here for discussion, rather than in the Collector. In the new PythonScripts product (that is a standard part of Zope 2.3) there is a standard utility module that can be imported into a Python Script with import Products.PythonScripts.standard or from Products.PythonScripts.standard import * It contains useful functions such as those for text formatting (html_quote, url_quote_plus, and so on). It also contains the DTML class for creating temporary chunks of restricted DTML. These functions would be really useful as part of the DTML _ namespace variable. I sometimes find myself wanting to use html_quote in a DTML expression. I'd also be able to use these functions from ZPatterns SkinScript. The PythonScripts product could add these functions to the _ namespace variable at product init time, so there would be no need to change the DocumentTemplate modules. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Steve Alexander wrote: <snip standard stuff>
These functions would be really useful as part of the DTML _ namespace variable. I sometimes find myself wanting to use html_quote in a DTML expression.
If you have something like that, wouldn't it be better, more readable, etc, for it to be moved intop a python script, even if that script was only 1 line long? eg: <dtml-if "mysomething(_['title_or_id'],_.standard.html_quote(absolute_url()+_[id]))"> becomes: <dtml-if mysomething_object_from_path_or_id>
I'd also be able to use these functions from ZPatterns SkinScript.
That's a seperate issue and oen I'm sure I'll agree with once I start using SkinScript ;-)
The PythonScripts product could add these functions to the _ namespace variable at product init time, so there would be no need to change the DocumentTemplate modules.
Hmmm... since they're both part of the Zope Core, does it make a lot of difference where it's done? cheers, Chris :-)
Chris Withers wrote:
If you have something like that, wouldn't it be better, more readable, etc, for it to be moved intop a python script, even if that script was only 1 line long?
eg: <dtml-if "mysomething(_['title_or_id'],_.standard.html_quote(absolute_url()+_[id]))">
You are being deliberately Byzantine there! Not to mention that _['title_or_id'] is equivalent to just title_or_id. However, I agree with you in principle. I've had other, much simpler, cases where I want to html_quote just a part of something. I can't put my finger on an example right now, so that does weaken my case a little :-) -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
Steve Alexander wrote:
eg: <dtml-if "mysomething(_['title_or_id'],_.standard.html_quote(absolute_url()+_[id]))">
You are being deliberately Byzantine there!
I provided a good example for my case, don't know what Byzantine means, erk :-S
However, I agree with you in principle. I've had other, much simpler, cases where I want to html_quote just a part of something. I can't put my finger on an example right now, so that does weaken my case a little :-)
*grinz* Chris
Steve Alexander wrote:
The PythonScripts product could add these functions to the _ namespace variable at product init time, so there would be no need to change the DocumentTemplate modules.
And here's a patch: Just add these lines at the end of lib/python/Products/PythonScripts/standard.py from DocumentTemplate.DT_Util import d import standard d['standard']=standard del standard Of course, you could add similar lines to PythonScripts/__init__.py, or in a completely new "enable python scripts standard module with dtml" product. -- Steve Alexander Software Engineer Cat-Box limited http://www.cat-box.net
participants (2)
-
Chris Withers -
Steve Alexander