weheh
unread,Sep 6, 2010, 11:17:01 AM9/6/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to web2py-users
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?