diff --git a/pyscript/README.txt b/pyscript/README.txt
index b9d2a5a..16d6ead 100644
--- a/pyscript/README.txt
+++ b/pyscript/README.txt
@@ -1,22 +1,22 @@
-============
-Python Pages
-============
+==============
+Python Scripts
+==============
-Persistent Python Page - Content Type
+Persistent Python Scripts
Examples:
>>> from cybertools.pyscript.tests import Root
- >>> from cybertools.pyscript.script import PythonPage
+ >>> from cybertools.pyscript.script import PythonScript
- >>> pp = PythonPage()
+ >>> pp = PythonScript()
>>> pp.__parent__ = Root()
>>> pp.__name__ = 'pp'
>>> request = None
Test that can produce the correct filename
- >>> pp._PythonPage__filename()
+ >>> pp._PythonScript__filename()
u'/pp'
A simple test that checks that any lone-standing triple-quotes are
@@ -24,50 +24,49 @@ being printed.
>>> pp.setSource(u"'''...'''\nreturn printed")
>>> pp(request)
- '...\n'
+ u'...\n'
Make sure that strings with prefixes work.
- >>> pp.setSource(ur"ur'''test\r'''" + "\nreturn printed")
+ >>> pp.setSource(ur"ur'''test\\r'''" + "\nreturn printed")
>>> pp(request)
- 'test\\r\n'
+ u'test\\r\n'
Make sure that Windows (\r\n) line ends also work.
>>> pp.setSource(u"if 1 == 1:\r\n\r\n '''...'''\nreturn printed")
>>> pp(request)
- '...\n'
+ u'...\n'
Make sure that unicode strings work as expected.
- >>> #pp.setSource(u"u'''\u0442\u0435\u0441\u0442'''")
- >>> #pp(request)
-
-u'\u0442\u0435\u0441\u0442\n'
+ >>> pp.setSource(u"u'''\u0442\u0435\u0441\u0442'''\nreturn printed")
+ >>> pp(request)
+ u'\u0442\u0435\u0441\u0442\n'
Make sure that multi-line strings work.
>>> pp.setSource(u"u'''test\ntest\ntest'''\nreturn printed")
>>> pp(request)
- 'test\n...test\n...test\n'
+ u'test\n...test\n...test\n'
Here you can see a simple Python command...
>>> pp.setSource(u"print u'...'\nreturn printed")
>>> pp(request)
- '...\n'
+ u'...\n'
... and here a triple quote with some variable replacement.
>>> pp.setSource(u"'''%s''' %x\nreturn printed")
>>> pp(request, x='test')
- 'test\n'
+ u'test\n'
Make sure that the context of the page is available.
>>> pp.setSource(u"'''%s''' %context.__name__\nreturn printed")
>>> pp(request)
- 'root\n'
+ u'root\n'
Make sure that faulty syntax is interpreted correctly.
diff --git a/pyscript/browser.py b/pyscript/browser.py
index dcc1777..e8c6543 100644
--- a/pyscript/browser.py
+++ b/pyscript/browser.py
@@ -20,17 +20,20 @@ from zope.app.form.browser.editview import EditView
from zope.app.i18n import ZopeMessageFactory as _
-class PythonPageEval(object):
- """Evaluate the Python Page."""
+class PythonScriptEval(object):
+ """Evaluate the Python Script."""
def index(self, **kw):
"""Call a Python Page"""
self.request.response.setHeader('content-type',
self.context.contentType)
- return str(self.context(self.request, **kw))
+ result = self.context(self.request, **kw)
+ if type(result) is unicode:
+ return result
+ return unicode(result)
-class PythonPageEditView(EditView):
+class PythonScriptEditView(EditView):
"""Edit View Class for Python Page."""
syntaxError = None
diff --git a/pyscript/configure.zcml b/pyscript/configure.zcml
index a4783a7..c9acdf3 100644
--- a/pyscript/configure.zcml
+++ b/pyscript/configure.zcml
@@ -4,19 +4,19 @@
i18n_domain="zope">
-
+