[ZCM] [ZC] 2311/ 4 Comment "Make it possible to call modules in DTML files"
"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Tue, 17 Apr 2007 11:20:28 -0400
| Newsgroups | gmane.comp.web.zope.devel.collector-monitor |
|---|---|
| Message-ID | <[email protected]> |
Issue #2311 Update (Comment) "Make it possible to call modules in DTML files"
Status Wontfix, Zope/feature low
To followup, visit:
http://www.zope.org/Collectors/Zope/2311
==============================================================
= Comment - Entry #4 by madarche on Apr 17, 2007 11:20 am
Thanks Tres for your comment.
> = Comment - Entry #3 by tseaver on Apr 14, 2007 1:32 pm
>
> For the original poster's use case, the canonical way to
> invoke such a module-level function from DTML is to add an
> external method which importes the function and exposes it.
>
And that's exactly what I'm using now to circumvent this lack in DTML, but it is awkward, not agile and it promotes the use of skin scripts instead of faster module code.
My point is : since it's legitimate to use DTML for non-SGML files (such as generated CSS and JavaScript) it should be legitimate to be able to call modules in DTML.
If the people taking the decision on this point disagree, I won't get mad since there is a work-around. I just wanted to suggest a useful improvement that promotes good practices.
________________________________________
= Comment - Entry #3 by tseaver on Apr 14, 2007 1:32 pm
> = Wontfix - Entry #2 by ajung on Apr 14, 2007 2:24 am
>
> Status: Pending => Wontfix
>
> We will not extend the functionality of DTML. DTML is dead and should
> only be used for ZSQL methods. Use ZPT in all other cases.
ZPT is actually a hideous choice for rendering non-SGML-like
content (e.g., dynamic CSS, dynamic JavaScript, etc.) I would
rephrase that as "use the appropriate tool for other renderings."
For the original poster's use case, the canonical way to
invoke such a module-level function from DTML is to add an
external method which importes the function and exposes it.
________________________________________
= Wontfix - Entry #2 by ajung on Apr 14, 2007 2:24 am
Status: Pending => Wontfix
We will not extend the functionality of DTML. DTML is dead and should only be used for ZSQL methods. Use ZPT in all other cases.
________________________________________
= Request - Entry #1 by madarche on Apr 13, 2007 8:25 am
Uploaded: "OneMoreUtilProduct.tar.gz"
- http://www.zope.org/Collectors/Zope/2311/OneMoreUtilProduct.tar.gz/view
In ZPT files one can call methods from modules.
For example :
<tal:block define="res python:modules['Products.OneMoreUtilProduct.integration'].isProductPresent('Products.CMFCore')">
<tal:block replace="res"/>
</tal:block>
In DTML files one cannot call methods from modules.
For example one cannot do :
p {
<dtml-if "modules['Products.OneMoreUtilProduct.integration'].isUserAgentGecko(REQUEST)">
-moz-border-radius: 4px;
</dtml-if>
}
Time 2007/04/13 14:13:52.544 GMT+2
User Name (User Id) admin (admin)
Request URL http://localhost:8084/portal/default.css
Exception Type NameError
Exception Value name 'modules' is not defined
Traceback (innermost last):
* Module ZPublisher.Publish, line 115, in publish
* Module ZPublisher.mapply, line 88, in mapply
* Module ZPublisher.Publish, line 41, in call_object
* Module Products.CMFCore.FSDTMLMethod, line 132, in __call__
__traceback_info__: OneMoreUtilProduct/skins/util/default.css.dtml
* Module DocumentTemplate.DT_String, line 476, in __call__
* Module DocumentTemplate.DT_Util, line 196, in eval
__traceback_info__: modules
* Module <string>, line 1, in <expression>
NameError: name 'modules' is not defined
If it's possible in ZPT files, it should be possible in DTML files too. Because one cannot use ZPT files for all usages. For example one should use DTML files for writing CSS declarations.
I'm attaching the archive OneMoreUtilProduct.tar.gz containing a Zope Product to test module calling both in ZPT and DTML.
Thank you if you can fix this.
==============================================================