From 714cc67541610154129ec3e072b478929d6c5d4c Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 15 Sep 2007 11:38:11 +0000 Subject: [PATCH] put all R handling to pyscript; add view for showing graphics (plots) from tmp files created by R git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2041 fd906abe-77d9-0310-91a1-e0d9ade77398 --- pyscript/plot.py | 5 ++++- pyscript/rstat.py | 2 +- pyscript/script.py | 6 +++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyscript/plot.py b/pyscript/plot.py index 7baf628..24158d9 100644 --- a/pyscript/plot.py +++ b/pyscript/plot.py @@ -43,7 +43,10 @@ class PlotView(object): return self def __call__(self): - path = str('/' + os.path.join(*self.traverse_subpath)) + if self.traverse_subpath: + path = str('/' + os.path.join(*self.traverse_subpath)) + else: + path = self.request.form.get('image') # TODO: keep path in temporary dictionary with hashed keys. self.setHeaders(path) f = open(path, 'rb') diff --git a/pyscript/rstat.py b/pyscript/rstat.py index 134ab08..126b3c2 100644 --- a/pyscript/rstat.py +++ b/pyscript/rstat.py @@ -43,7 +43,7 @@ class RWrapper(object): return RWrapper(value) -r = RWrapper(r) +rx = RWrapper(r) with_mode = RWrapper(rpy.with_mode) #as_py = RWrapper(rpy.as_py) diff --git a/pyscript/script.py b/pyscript/script.py index 387727b..83a4bba 100644 --- a/pyscript/script.py +++ b/pyscript/script.py @@ -38,7 +38,9 @@ from zope.traversing.api import getParent, getPath from cybertools.pyscript.interfaces import IPythonScript, IScriptContainer try: - from cybertools.pyscript.rstat import r, rpy + #from cybertools.pyscript.rstat import r, rpy + import rpy + from rpy import r HAS_R = True except ImportError: HAS_R = False @@ -191,4 +193,6 @@ class ScriptContainer(BTreeContainer): if HAS_R: from cybertools.pyscript import rstat globs['rstat'] = rstat + globs['r'] = r + globs['rpy'] = rpy