template compiles with python 3.0
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.2.1 (2012-10-23 10:28:41) stable
|
Version 2.2.1 (2012-10-23 10:45:12) stable
|
||||||
|
|||||||
+10
-6
@@ -16,9 +16,13 @@ Contributors:
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import cgi
|
import cgi
|
||||||
import cStringIO
|
|
||||||
import logging
|
import logging
|
||||||
from re import compile, sub, escape, DOTALL
|
from re import compile, sub, escape, DOTALL
|
||||||
|
try:
|
||||||
|
import cStringIO as StringIO
|
||||||
|
except:
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# have web2py
|
# have web2py
|
||||||
from restricted import RestrictedError
|
from restricted import RestrictedError
|
||||||
@@ -791,13 +795,13 @@ def get_parsed(text):
|
|||||||
|
|
||||||
class DummyResponse():
|
class DummyResponse():
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.body = cStringIO.StringIO()
|
self.body = StringIO.StringIO()
|
||||||
|
|
||||||
def write(self, data, escape=True):
|
def write(self, data, escape=True):
|
||||||
if not escape:
|
if not escape:
|
||||||
self.body.write(str(data))
|
self.body.write(str(data))
|
||||||
elif hasattr(data, 'xml') and callable(data.xml):
|
elif hasattr(data, 'as_html') and callable(data.as_html):
|
||||||
self.body.write(data.xml())
|
self.body.write(data.as_html())
|
||||||
else:
|
else:
|
||||||
# make it a string
|
# make it a string
|
||||||
if not isinstance(data, (str, unicode)):
|
if not isinstance(data, (str, unicode)):
|
||||||
@@ -870,7 +874,7 @@ def render(content="hello world",
|
|||||||
# save current response class
|
# save current response class
|
||||||
if context and 'response' in context:
|
if context and 'response' in context:
|
||||||
old_response_body = context['response'].body
|
old_response_body = context['response'].body
|
||||||
context['response'].body = cStringIO.StringIO()
|
context['response'].body = StringIO.StringIO()
|
||||||
else:
|
else:
|
||||||
old_response_body = None
|
old_response_body = None
|
||||||
context['response'] = Response()
|
context['response'] = Response()
|
||||||
@@ -887,7 +891,7 @@ def render(content="hello world",
|
|||||||
stream = open(filename, 'rb')
|
stream = open(filename, 'rb')
|
||||||
close_stream = True
|
close_stream = True
|
||||||
elif content:
|
elif content:
|
||||||
stream = cStringIO.StringIO(content)
|
stream = StringIO.StringIO(content)
|
||||||
|
|
||||||
# Execute the template.
|
# Execute the template.
|
||||||
code = str(TemplateParser(stream.read(
|
code = str(TemplateParser(stream.read(
|
||||||
|
|||||||
Reference in New Issue
Block a user