[Zope-dev] Problem with StructuredText and expandtabs
Bill Anderson
anderson@hp.com
13 Aug 2001 13:02:43 -0600
On 13 Aug 2001 10:55:32 -0400, Ken Manheimer wrote:
> On Wed, 07 Aug 2001 Bill Anderson <anderson@hp.com> wrote:
>
> > On 07 Aug 2001 19:29:36 +0200, Dieter Maurer wrote:
> > > Bill Anderson writes:
> > > > I am trying to use StructuredText outside Zope. I can import it fine,
> > > > but when I try to use it I get:
> > > >
> > > > ======================================
> > > > >>> st=StructuredText.Basic(raw)
> > > > Traceback (most recent call last):
> > > > File "<stdin>", line 1, in ?
> > > > File "ST.py", line 113, in StructuredText
> > > > paragraphs = expandtabs(paragraphs)
> > > > File "/usr/lib/python2.1/string.py", line 295, in expandtabs
> > > > return s.expandtabs(tabsize)
> > > > AttributeError: expandtabs
> > > Apparently, your "s" is not a string...
> >
> > That is what I was concluding, the question is, Why not? I took my
> > structured text file from a zope (CMF) document from the same machine,
> > where it works fine. The issue _seems_ to me to be that
> > it works fine from withni Zope, but not from without. Same Zope machine,
> > same Zope code, same structured text. :(
>
> What's the value of 'raw'?
>
> % python
> Python 2.1.1 (#3, Jul 20 2001, 15:19:25)
> [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> from StructuredText import StructuredText
> >>> StructuredText.Basic("Paragraph.")
> StructuredTextDocument([
> StructuredTextParagraph(Paragraph., [
> ]),
> ])
> >>>
>
> If i was sure 'raw' was a string, on getting the traceback i would resort
> to debugging using pdb post-mortem - 'import pdb; pdb.pm()'. Examine the
> value of 's' in the bottom stack frame, and then ascend the stack with 'u'
> and poke around there...
>
As it turns out, I was forgetting the .read() on reading the file, and
consequently was sending s as a file descriptor :)
Fixed and working perfectly now ... though I found something that needs
patched. :)
ST and STNG return <li><p> for list items, when only the <li> should be
returned. THis causes some nastyeffects when converting to html, and
then to htmldoc-built pdf files. The line item appears a line below the
bullet point.
Bill