Re: Problem with embedded Python code blocks

"Will Guaraldi" <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
On 9/7/07, Chris G <[email protected]> wrote:
> On Thu, Sep 06, 2007 at 06:22:07PM -0400, Will Guaraldi wrote:
> > The embedded python blocks are a feature of my plugins--they're not
> > something that works in the PyBlosxom core template system.  So this
> > would only work for pages being served by wbgwiki, pystaticfile, and
> > pyinclude.
> >
> > Do the examples in the wbgwiki documentation work?
> >
> As far as I can tell only single line embedded code works.
>
> E.g. I have created a file called wikiTxt.txt in my wiki hierarchy
> which contains:-
>
>     WikiTest
>
>
>     <%
>     print "testing"
>     %>
>
>     <%
>         x = { "apple": 5, "banana": 6, "pear": 4 }
>         for mem in x.keys():
>             print "<li>%s - %s</li>" % (mem, x[mem])
>     %>
>
>
>
> ... and the output in my browser is:-
>
>
>     WikiTest
>
>     testing ERROR in processing: unexpected indent (, line 2)
>     [ category: /wiki | Permalink ]
>
>
> I.e. the single line print works but the multi-line assignment plus
> for loops fails.  This seems to agree with what I was seeing before,
> single line bits of embedded python work but anything multi-line just
> causes confusion.

Ok--this is an error from the wbgwiki python block parsing.  This type
of code works for me, so it's something with your setup.

Try unindenting the second block of code so that it's flush with the left side.


> If I rename the same file to wikiRst.rst so it gets parsed by the
> reStructured text parser then I see the following in my browser:-
>
>     WikiTest
>
>     <% print "testing" %>
>
>     <%
>
>         x = { "apple": 5, "banana": 6, "pear": 4 } for mem in x.keys():
>
>         System Message: ERROR/3 (<string>, line 10)
>         Unexpected indentation.
>
>             print "<li>%s - %s</li>" % (mem, x[mem])
>
>     System Message: WARNING/2 (<string>, line 11)
>     Definition list ends without a blank line; unexpected unindent.
>
>     %>
>     [ category: /wiki | Permalink ]

I think this is an reST syntax error and not a wbgwiki block parsing error.

/will

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.