Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Iliya Manolov
erp5
Commits
e17cf968
Commit
e17cf968
authored
Jun 08, 2017
by
Iliya Manolov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a function to JupyterCompile that checks if notebooks with a given and owner reference exist
parent
3e94dc37
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
5 deletions
+61
-5
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
...teItem/portal_components/extension.erp5.JupyterCompile.py
+9
-5
bt5/erp5_data_notebook/SkinTemplateItem/portal_skins/erp5_data_notebook/Base_checkExistingReference.xml
..._skins/erp5_data_notebook/Base_checkExistingReference.xml
+28
-0
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
...ateItem/portal_components/test.erp5.testExecuteJupyter.py
+24
-0
No files found.
bt5/erp5_data_notebook/ExtensionTemplateItem/portal_components/extension.erp5.JupyterCompile.py
View file @
e17cf968
...
@@ -867,9 +867,6 @@ class ImportFixer(ast.NodeTransformer):
...
@@ -867,9 +867,6 @@ class ImportFixer(ast.NodeTransformer):
if
not
self
.
import_func_dict
.
get
(
name
):
if
not
self
.
import_func_dict
.
get
(
name
):
final_module_names
.
append
(
name
)
final_module_names
.
append
(
name
)
log
(
"module_names[0]: "
+
module_names
[
0
])
log
(
"result_name: "
+
result_name
)
if
final_module_names
:
if
final_module_names
:
# try to import module before it is added to environment
# try to import module before it is added to environment
# this way if user tries to import non existent module Exception
# this way if user tries to import non existent module Exception
...
@@ -879,8 +876,6 @@ class ImportFixer(ast.NodeTransformer):
...
@@ -879,8 +876,6 @@ class ImportFixer(ast.NodeTransformer):
empty_function
=
self
.
newEmptyFunction
(
"%s_setup"
%
result_name
)
empty_function
=
self
.
newEmptyFunction
(
"%s_setup"
%
result_name
)
return_dict
=
self
.
newReturnDict
(
final_module_names
)
return_dict
=
self
.
newReturnDict
(
final_module_names
)
log
(
return_dict
)
empty_function
.
body
=
[
node
,
return_dict
]
empty_function
.
body
=
[
node
,
return_dict
]
environment_set
=
self
.
newEnvironmentSetCall
(
"%s_setup"
%
result_name
)
environment_set
=
self
.
newEnvironmentSetCall
(
"%s_setup"
%
result_name
)
warning
=
self
.
newImportWarningCall
(
root_module_name
,
result_name
)
warning
=
self
.
newImportWarningCall
(
root_module_name
,
result_name
)
...
@@ -1180,3 +1175,12 @@ def erp5PivotTableUI(self, df):
...
@@ -1180,3 +1175,12 @@ def erp5PivotTableUI(self, df):
iframe_host
=
self
.
REQUEST
[
'HTTP_X_FORWARDED_HOST'
].
split
(
','
)[
0
]
iframe_host
=
self
.
REQUEST
[
'HTTP_X_FORWARDED_HOST'
].
split
(
','
)[
0
]
url
=
"https://%s/erp5/Base_displayPivotTableFrame?key=%s"
%
(
iframe_host
,
key
)
url
=
"https://%s/erp5/Base_displayPivotTableFrame?key=%s"
%
(
iframe_host
,
key
)
return
IFrame
(
src
=
url
,
width
=
'100%'
,
height
=
'500'
)
return
IFrame
(
src
=
url
,
width
=
'100%'
,
height
=
'500'
)
def
Base_checkExistingReference
(
self
,
reference
):
existing_notebook
=
self
.
portal_catalog
.
getResultValue
(
owner
=
self
.
portal_membership
.
getAuthenticatedMember
().
getUserName
(),
portal_type
=
'Data Notebook'
,
reference
=
reference
)
if
not
existing_notebook
is
None
:
return
True
return
False
bt5/erp5_data_notebook/SkinTemplateItem/portal_skins/erp5_data_notebook/Base_checkExistingReference.xml
0 → 100644
View file @
e17cf968
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
Base_checkExistingReference
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
JupyterCompile
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_checkExistingReference
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py
View file @
e17cf968
...
@@ -32,6 +32,8 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPyth
...
@@ -32,6 +32,8 @@ from Products.ERP5Type.tests.utils import createZODBPythonScript, removeZODBPyth
import
time
import
time
import
json
import
json
import
base64
import
base64
import
random
import
string
class
TestExecuteJupyter
(
ERP5TypeTestCase
):
class
TestExecuteJupyter
(
ERP5TypeTestCase
):
...
@@ -857,3 +859,25 @@ print dig
...
@@ -857,3 +859,25 @@ print dig
self
.
assertEquals
(
result
[
'status'
],
'ok'
)
self
.
assertEquals
(
result
[
'status'
],
'ok'
)
self
.
assertEquals
(
result
[
'code_result'
].
strip
(),
'0123456789'
)
self
.
assertEquals
(
result
[
'code_result'
].
strip
(),
'0123456789'
)
def
testReferenceWarning
(
self
):
'''
Tests Base_checkExistingReference in JupyterCompile.
'''
self
.
login
(
'dev_user'
)
notebook_reference
=
u''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
30
))
notebook_title
=
u''
.
join
(
random
.
choice
(
string
.
ascii_lowercase
)
for
_
in
range
(
30
))
notebook_module
=
self
.
portal
.
getDefaultModule
(
portal_type
=
'Data Notebook'
)
data_notebook
=
notebook_module
.
DataNotebookModule_addDataNotebook
(
title
=
notebook_title
,
reference
=
notebook_reference
,
batch_mode
=
True
)
self
.
tic
()
result
=
self
.
portal
.
Base_checkExistingReference
(
reference
=
notebook_reference
,
)
self
.
tic
()
self
.
assertEquals
(
result
,
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment