Re: Problem with embedded Python code blocks

Chris G <[email protected]>
Newsgroups gmane.comp.web.pyblosxom.user
Message-ID <[email protected]>
On Fri, Sep 07, 2007 at 09:49:59AM -0400, Will Guaraldi wrote:
> On 9/7/07, Chris G <[email protected]> wrote:
> > On Thu, Sep 06, 2007 at 06:22:07PM -0400, Will Guaraldi wrote:
> > > 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.
>
Aha (I finally got around to trying it) that works OK, thanks.

> 
> 
> > 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.
> 
You're right of course, those are docutils/reST errors aren't they,
does this mean one can't really use multi-line embedded python in reST
or does it mean it needs some diabolical sort of quoting?

I'll experiment some more.

-- 
Chris Green

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
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.