DTMLTemplate + PythonMethod == separate code from HTML?
In fact, I find it too hard to code something using DTML, that's why I'd like to use good old python and to keep only variable substitution in my HTML (dtml-var, or maybe just &dtml-my_variable; which is an easier to use form of it, or maybe replace it with @my_var@ or smth like that, which I would find even easier!) I'd like to be able to delimit blocks in an HTML file and to use these blocks from a python program, the goal is to completely separate the code from the design (HTML). With DTML, the code and the design are mixed. it would look like this: def index_html(_): "Display a list of items taken from the products database" if not check_password(): return bad_password_page query_result = my_zsql_query(_) if not query_result: return my_template.no_result result = ReturnStream() result.add( my_template.header ) for line in query.result: result.add( my_template.one_line, line ) result.add( my_template.footer ) and my_template would be an HTML file with <dtml-block> tags that delimit the header, one_line and footer blocks. The one_line block would use some variables defined in the line dictionary; for example: <dtml-block one_line> <tr><td>@item@</td><td>@quantity@</td><td>@price@</td></tr> </dtml-block> The DTMLTemplate and PythonMethods products seem to provide this kind of separation between code and design, but I did not manage to get them working properly together: DTMLTemplate: when I display a block (using <dtml-var "my_template.my_block">), the HTML tags in my_block appear quoted, should I use a fmt="html" or something like that to avoid the quoting? PythonMethods: how can I access Zope objects from my method? Typically I'd like to call a template block from my method, but just using my_template.my_block doesn't work. As you can see, I'm not a Zope guru, but I'm willing to learn! I believe that Zope and PTK have a big role to play in the current portal and application servers war... ready to use portal-in-a-box products cost around $100,000... so for that price you can use zope and afford more consulting and coding services! BTW, currently I'm experiencing a problem: no images (icons, ZopeButton etc..) appear on my management pages, images stored in the ZODB are ok though. any idea where are those images like http://localhost:8080/p_/ZopeButton ? Thanks for your time!
Thiebaut CHAMPENIER wrote:
The DTMLTemplate and PythonMethods products seem to provide this kind of separation between code and design, but I did not manage to get them working properly together:
they do provide this level of separation. another option to check out with this kinda of separation are the hiperdom templates (search hiperdom on zope.org, not quite ready for prime time)
DTMLTemplate: when I display a block (using <dtml-var "my_template.my_block">), the HTML tags in my_block appear quoted, should I use a fmt="html" or something like that to avoid the quoting?
when you switch to pythonish dtml ala " " you need to explicitly pass in the args the method expects for proper rendering. <dtml-var "my_template.my_block("_.None,_)">
PythonMethods: how can I access Zope objects from my method? Typically I'd like to call a template block from my method, but just using my_template.my_block doesn't work.
same thing i think, return my_template.my_block(_.None, _)
As you can see, I'm not a Zope guru, but I'm willing to learn! I believe that Zope and PTK have a big role to play in the current portal and application servers war... ready to use portal-in-a-box products cost around $100,000... so for that price you can use zope and afford more consulting and coding services!
there are several other quality open source portal solutions. to name a few arsdigita.com, java.apache.org/jetspeed, metadot.com
BTW, currently I'm experiencing a problem: no images (icons, ZopeButton etc..) appear on my management pages, images stored in the ZODB are ok though. any idea where are those images like http://localhost:8080/p_/ZopeButton ?
there some stuff on this in the mailing list archives. kapil
participants (2)
-
Ender -
Thiebaut CHAMPENIER