Using ReStructuredText instead of StructuredDocument inside ZPT
Hello, I have been using the Structured Document (SD) product with page templates (to provide some content sections that a client can edit using structured text). Now I would like to use ReStructuredText Document (RSTD) instead of SD. I have been using code like this in a page template to render the content of a SD within the page template: ... <div metal:fill-slot="pagebody"> <p tal:content="structure container/client_content/vision_statement"> Vision Statement </p> </div> <!-- end of page body slot --> ... ...where vision_statement is a SD object. I expected that this would work the same if vision_statement were a RSTD object...however it does not. What displays is only the unrendered, plain text content of the RSTD. Can I use a RSTD object in the same way I have been using a SD? If so, how do I get it to render? This is on zope 2.7.5 with the ZReST that comes "built in." A RSTD called directly (instead of inside a ZPT as above) renders as expected. thanks, John S. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--On 23. Februar 2006 23:18:06 -0800 John Schinnerer <johnschinnerer@yahoo.com> wrote:
This is on zope 2.7.5 with the ZReST that comes "built in." A RSTD called directly (instead of inside a ZPT as above) renders as expected.
Try using the 'render()' method. -aj
Hello, OK, that makes sense in general - and what would that look like in my ZPT code? Can I access that method with just TAL, similar to Structured Document example: <p tal:content="structure container/client_content/some_STX_object"> STX content renders here </p> ...except with the render() in the path somewhere - where? Or do I have to use a python expression, and if so what would that look like? The only documentation I can find so far is the user documentation... thanks, John S. --- Andreas Jung <lists@andreas-jung.com> wrote:
--On 23. Februar 2006 23:18:06 -0800 John Schinnerer <johnschinnerer@yahoo.com> wrote:
This is on zope 2.7.5 with the ZReST that comes "built in." A RSTD called directly (instead of inside a ZPT as above) renders
as
expected.
Try using the 'render()' method.
-aj
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--On 24. Februar 2006 16:36:20 -0800 John Schinnerer <johnschinnerer@yahoo.com> wrote:
Hello,
OK, that makes sense in general - and what would that look like in my ZPT code? Can I access that method with just TAL, similar to Structured Document example:
<p tal:content="structure container/client_content/some_STX_object"> STX content renders here </p>
...except with the render() in the path somewhere - where?
huh? You should be able to extend the expression above by calling the objects render method? <p tal:content="structure container/client_content/some_STX_object/render"> Consider reading about how path expressions work. -aj
Aloha,
huh? You should be able to extend the expression above by calling the objects render method?
<p tal:content="structure container/client_content/some_STX_object/render">
OK, tried that - I get a username/password prompt that won't take anything as authorized, and I end up with this error: ----------------- Site Error An error was encountered while publishing this resource. Error Type: Unauthorized Error Value: You are not allowed to access 'render' in this context ------------------ I can post the full trace if needed, seems like overkill at this point as I assume it's some kind of general security thing with ReST Document that I simply don't know about. So now what? Even the zope instance root/owner username and PW are not accepted...?? If it's to be useful to me I need it to just render for Anonymous as it's part of public site content. thanks, John S. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
John Schinnerer wrote:
Aloha,
huh? You should be able to extend the expression above by calling the objects render method?
<p tal:content="structure container/client_content/some_STX_object/render">
OK, tried that - I get a username/password prompt that won't take anything as authorized, and I end up with this error: ----------------- Site Error
An error was encountered while publishing this resource.
Error Type: Unauthorized Error Value: You are not allowed to access 'render' in this context ------------------
I can post the full trace if needed, seems like overkill at this point as I assume it's some kind of general security thing with ReST Document that I simply don't know about.
So now what? Even the zope instance root/owner username and PW are not accepted...??
In your Zope distribution files look at 'doc/RESTRUCTUREDSTEXT.txt' (or 'Zope/doc/RESTRUCTUREDSTEXT.txt' with Zope2.9). It has examples of how to use ReST with different solutions. (There is a typo: 'restructured_test' should read 'restructured_text' ) Btw, the ZReST objects method 'source_txt' gets you the source text of the reST document. E.g. this should work in your example: <p tal:define="rest_txt python:container.client_content.some_STX_object.source_txt()" tal:replace="structure python: modules['Products.PythonScripts.standard'].restructured_text(rest_txt)" /> Hth, Michael -- http://zope.org/Members/d2m http://planetzope.org
Aloha, Thanks for pointing me to that document, that's what I needed. The example for TAL integration works just fine (with the typo fixed :-), and also renders only the actual content, without adding the whole XHTML document structure around it. cheers, John S.
In your Zope distribution files look at 'doc/RESTRUCTUREDSTEXT.txt' (or 'Zope/doc/RESTRUCTUREDSTEXT.txt' with Zope2.9).
It has examples of how to use ReST with different solutions. (There is a typo: 'restructured_test' should read 'restructured_text' )
Btw, the ZReST objects method 'source_txt' gets you the source text of the reST document.
E.g. this should work in your example:
<p tal:define="rest_txt python:container.client_content.some_STX_object.source_txt()" tal:replace="structure python:
modules['Products.PythonScripts.standard'].restructured_text(rest_txt)"
/>
Hth, Michael
-- http://zope.org/Members/d2m http://planetzope.org
_______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )
__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com
--On 25. Februar 2006 20:13:49 -0800 John Schinnerer <johnschinnerer@yahoo.com> wrote:
Aloha,
huh? You should be able to extend the expression above by calling the objects render method?
<p tal:content="structure container/client_content/some_STX_object/render">
My fault, try 'index_html' instead of 'render'. -aj
participants (3)
-
Andreas Jung -
John Schinnerer -
Michael Haubenwallner