Re: [Zope] How to use DocumentTemplate custom formats from Python?
I wrote: I'm using DocumentTemplate from Python (not in Zope) and I want to use a custom format 'javascript_quote' that I've written. Kapil Thangavelu wrote: you should implement a formating function and register it with special_format. for examples of both look near the end /DocumentTemplate/DT_Var.py Thanks. I did as below, which worked. Is that the official way? - I couldn't see any dedicated function to register a format. DT_Var.special_formats['javascript_quote'] = javascript_quote Hamish Lawson Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to use DocumentTemplate custom formats from Python?
Dieter Maurer wrote: All other "*_quote" features are implemented via *arguments* (sql_quote, html_quote, url_quote). Why do you want to make your "javascript_quote" a format? Note, that you may want to quote a (otherwise) formatted value. I don't especially want to make it a format rather than a modifier - I take your point about being able to modify a formatted value. Before I was directed to the DT_Var module, I had been going just on what is in the DTML Reference, where it mentions only custom formats. I've now had a look at the DT_Var module, but I don't see an obvious way to register my own modifier without hacking the module. Hamish Lawson = Hamish Lawson [EMAIL PROTECTED] Do You Yahoo!? Get your free @yahoo.co.uk address at http://mail.yahoo.co.uk or your free @yahoo.ie address at http://mail.yahoo.ie ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Re: [Zope] How to use DocumentTemplate custom formats from Python?
Hamish Lawson wrote: I'm using DocumentTemplate from Python (not in Zope) and I want to use a custom format 'javascript_quote' that I've written. In my DTML file I have: [snip] you should implement a formating function and register it with special_formats for examples of both look near the end /DocumentTemplate/DT_Var.py Kapil Another suggestion -- If the thing identified by the 'name' attribute is an instance of a class that you have implemented, then implement javascript_quote as a method in that class. If not, then use Kapil's suggestion above. In either case, you can find the relevant code in /DocumentTemplate/DT_Var.py. Search for 'special_formats' to find out how DocumentTemplate processing does the lookup and applies the formatting format/function/method. - Dave ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev ) ___ Zope maillist - [EMAIL PROTECTED] http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )