I already tried that and got the same ticket: NameError: global name
're' is not defined

I also put import re in the controller that imports the serializer. No
joy.

On Sep 6, 11:20 am, mdipierro <[email protected]> wrote:
> This is a python thing. Not sure why it works the way it does. Put
> import re outside the function and it will work.
>
> On Sep 6, 10:17 am, weheh <[email protected]> wrote:
>
> > I've written my own serializer, which I've stored locally under
> > modules.
>
> > I've imported the serializer in my controller with the statement
>
> >   module=local_import('serializer') # note: the v3 doc does not
> > include quotes around the name of the module
>
> > So far, so good. However, the serializer uses regular expressions, so
> > I do an import re within the serializer:
>
> > def my_dummy_serializer(text,tag=None,attr={}):
> >   import re # this is throwing a ticket!
> >   if tag==None: return re.sub('\s+',' ',text)
> >   if tag=='br': return '\n\n'
> >   if tag=='h1': return text
> >   if tag=='h2': return text
> >   if tag=='h3': return text
> >   if tag=='h4': return text
> >   if tag=='p': return text
> >   if tag=='b' or tag=='strong': return text
> >   if tag=='em' or tag=='i': return text
> >   if tag=='tt' or tag=='code': return text
> >   if tag=='a': return text
> >   if tag=='img': return text
> >   return text
>
> > The import re throws a ticket:
>
> > NameError: global name 're' is not defined
>
> > Suggestions?

Reply via email to