From e35a6607ce4cf7b3be67c8203bc717546f75bc84 Mon Sep 17 00:00:00 2001 From: Klaus Woelfel <klaus@nexedi.com> Date: Tue, 28 Mar 2017 17:32:00 +0000 Subject: [PATCH] Allow to use pd.DataFrame class functions and access recarray in sanbox --- product/Wendelin/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/product/Wendelin/__init__.py b/product/Wendelin/__init__.py index 7d61972..cad9a6b 100644 --- a/product/Wendelin/__init__.py +++ b/product/Wendelin/__init__.py @@ -29,7 +29,7 @@ Wendelin is a product containing general purpose tools to handle big data manipulations. """ -from AccessControl import allow_module, allow_type +from AccessControl import allow_module, allow_type, allow_class # we neeed to allow access to numpy's internal types import numpy as np @@ -45,6 +45,10 @@ for dtype in ('int8', 'int16', 'int32', 'int64', \ sz = np.array([(0,)], dtype = [('f0', dtype)]) allow_type(type(sz[0])) allow_type(type(sz)) + + rz = np.rec.array(np.array([(0,)], dtype = [('f0', dtype)])) + allow_type(type(rz[0])) + allow_type(type(rz)) allow_module('sklearn') allow_module('scipy') @@ -61,11 +65,14 @@ allow_type(pd.Timestamp) allow_type(pd.DatetimeIndex) allow_type(pd.DataFrame) +allow_class(pd.DataFrame) + # Modify 'safetype' dict in full_write_guard function # of RestrictedPython (closure) directly To allow # write access to ndarray and ZBigArray objects from RestrictedPython.Guards import full_write_guard full_write_guard.func_closure[1].cell_contents.__self__[np.ndarray] = True +full_write_guard.func_closure[1].cell_contents.__self__[np.core.records.recarray] = True from wendelin.bigarray.array_zodb import ZBigArray full_write_guard.func_closure[1].cell_contents.__self__[ZBigArray] = True -- 2.30.9