This is like KSS question: why we resolve a question with the first way we find? not the better one? Is the human being. But as Steve Jobs said some time ago: only excelence people don't stop in the first way to resolve a problem When I meet Zope for the first time I was absolutely impress with it There was nothing better to represent an object universe I know that Zopers have their own way (this was discuss some time ago, too) but my ideal scenario will be a minimalism Zope where everything was an URL In this ideal scenario you could ask for an URL with or without parameters as if you ask for to the browser We stop this theme to wait for a Plone2PDF or similar. I hope we could solve this in a simple way (I think if this needs a more complicated solution we will have failed) I only need to put a link with the PDF download to the current page! (this don't sound to much complicated, isn't it?) 2008/10/12 Dieter Maurer <dieter@handshake.de>
Garito wrote at 2008-10-11 16:39 +0200:
Did you imagine another way to do what I need to do?
I have not followed intensively "what you need to do". Thus, what follows may not be adequate.
When I remember right, then a PageTemplate's namespace is passed on to a "Script (Python)" when this script binds "namespace". Thus, this way you get access to the variables defined in the template.
A simple path "var/s1/.../sn" is roughly requivalent to
x = var.restricedTraverse("s1/.../sn") if callable(x): x = x() # "callable" may not be available in "Script (Python)"
If the path contains "?var", these must be resolved beforehand.
More complex paths "p1 | p2 | ... pn" are roughly equivalent to
exc = None for p in (p1, p2, ... pn): try: return path1(p, ...) except <some standard exceptions>: exc = sys.exc_info() if exc is not None: raise exc[0], exc[1], exc[2]
The most difficult part are for paths where "pn" is not a path expression but an arbitrary one. In this case, the concrete TALES implementation will be required for an interpretation.
Along this outline, a function "path(path_expr, variable_binding)" can be defined which roughly behaves like "path(path_expr)" in a PageTemplate with the current variable binding expressed as "variable_binding".
For simple cases, this function could be implemented in untrusted code. Complex cases will require access to the TALES implementation and therefore probably trusted code.
-- Dieter
-- Mis Cosas http://blogs.sistes.net/Garito Zope Smart Manager http://blogs.sistes.net/Garito/670