From 998cbf59cd8eee4dc145da18b6efe10299d15c41 Mon Sep 17 00:00:00 2001 From: helmutm Date: Sat, 29 Mar 2008 15:51:02 +0000 Subject: [PATCH] make loading of R depend on environment variable USE_RLIBRARY git-svn-id: svn://svn.cy55.de/Zope3/src/cybertools/trunk@2482 fd906abe-77d9-0310-91a1-e0d9ade77398 --- pyscript/script.py | 23 +++++++++++++---------- pyscript/tests.py | 17 +++-------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/pyscript/script.py b/pyscript/script.py index c344a15..048f26b 100644 --- a/pyscript/script.py +++ b/pyscript/script.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2007 Helmut Merz helmutm@cy55.de +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -21,8 +21,7 @@ $Id$ """ -import new -import re +import os, re import compiler.pycodegen from cStringIO import StringIO from persistent import Persistent @@ -37,13 +36,17 @@ from zope.security.untrustedpython.rcompile import RestrictionMutator as BaseRM from zope.traversing.api import getParent, getPath from cybertools.pyscript.interfaces import IPythonScript, IScriptContainer -try: - #from cybertools.pyscript.rstat import r, rpy - import rpy - from rpy import r - HAS_R = True -except ImportError: - HAS_R = False + +HAS_R = use_R = bool(os.environ.get('USE_RLIBRARY', True)) + +if use_R: + try: + #from cybertools.pyscript.rstat import r, rpy + import rpy + from rpy import r + HAS_R = True + except ImportError: + HAS_R = False unrestricted_objects = ('rpy', 'r', 'as_py', 'rstat') diff --git a/pyscript/tests.py b/pyscript/tests.py index 2b82620..111176e 100644 --- a/pyscript/tests.py +++ b/pyscript/tests.py @@ -1,17 +1,6 @@ -############################################################################## -# -# Copyright (c) 2004 Zope Corporation and Contributors. -# All Rights Reserved. -# -# This software is subject to the provisions of the Zope Public License, -# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. -# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED -# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS -# FOR A PARTICULAR PURPOSE. -# -############################################################################## -"""Tests for Python Page +"""Tests for pyscript + +Based on Zope Python Page. $Id$ """