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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ludovic Kiefer
erp5
Commits
decf8d39
Commit
decf8d39
authored
Aug 21, 2020
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ZODB Components: Migrate ContributionTool from filesystem.
parent
59c46956
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
207 additions
and
65 deletions
+207
-65
product/ERP5/__init__.py
product/ERP5/__init__.py
+1
-2
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Document.py
...tTemplateItem/portal_components/document.erp5.Document.py
+1
-1
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.ContributionTool.py
...plateItem/portal_components/tool.erp5.ContributionTool.py
+4
-62
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.ContributionTool.xml
...lateItem/portal_components/tool.erp5.ContributionTool.xml
+110
-0
product/ERP5/bootstrap/erp5_core/bt/template_tool_component_id_list
...P5/bootstrap/erp5_core/bt/template_tool_component_id_list
+1
-0
product/ERP5Type/ZopePatch.py
product/ERP5Type/ZopePatch.py
+1
-0
product/ERP5Type/patches/urllib_opener.py
product/ERP5Type/patches/urllib_opener.py
+89
-0
No files found.
product/ERP5/__init__.py
View file @
decf8d39
...
@@ -43,7 +43,7 @@ product_path = package_home( globals() )
...
@@ -43,7 +43,7 @@ product_path = package_home( globals() )
# Define object classes and tools
# Define object classes and tools
from
Tool
import
CategoryTool
,
IdTool
,
TemplateTool
,
\
from
Tool
import
CategoryTool
,
IdTool
,
TemplateTool
,
\
AlarmTool
,
\
AlarmTool
,
\
TrashTool
,
ContributionTool
,
\
TrashTool
,
\
SolverTool
SolverTool
import
ERP5Site
import
ERP5Site
from
Document
import
PythonScript
,
SQLMethod
from
Document
import
PythonScript
,
SQLMethod
...
@@ -56,7 +56,6 @@ portal_tools = ( CategoryTool.CategoryTool,
...
@@ -56,7 +56,6 @@ portal_tools = ( CategoryTool.CategoryTool,
TemplateTool
.
TemplateTool
,
TemplateTool
.
TemplateTool
,
AlarmTool
.
AlarmTool
,
AlarmTool
.
AlarmTool
,
TrashTool
.
TrashTool
,
TrashTool
.
TrashTool
,
ContributionTool
.
ContributionTool
,
SolverTool
.
SolverTool
,
SolverTool
.
SolverTool
,
)
)
content_classes
=
()
content_classes
=
()
...
...
product/ERP5/bootstrap/erp5_core/DocumentTemplateItem/portal_components/document.erp5.Document.py
View file @
decf8d39
...
@@ -37,7 +37,7 @@ from Products.ERP5Type import Permissions, PropertySheet
...
@@ -37,7 +37,7 @@ from Products.ERP5Type import Permissions, PropertySheet
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.XMLObject
import
XMLObject
from
Products.ERP5Type.Utils
import
deprecated
,
guessEncodingFromText
from
Products.ERP5Type.Utils
import
deprecated
,
guessEncodingFromText
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5Type.TransactionalVariable
import
getTransactionalVariable
from
Products.ERP5.T
ool.ContributionTool
import
MAX_REPEAT
from
erp5.component.t
ool.ContributionTool
import
MAX_REPEAT
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
NegatedQuery
from
Products.ZSQLCatalog.SQLCatalog
import
Query
,
NegatedQuery
from
AccessControl
import
Unauthorized
from
AccessControl
import
Unauthorized
import
zope.interface
import
zope.interface
...
...
product/ERP5/
Tool/
ContributionTool.py
→
product/ERP5/
bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.
ContributionTool.py
View file @
decf8d39
...
@@ -29,7 +29,6 @@
...
@@ -29,7 +29,6 @@
import
cStringIO
import
cStringIO
import
re
import
re
import
socket
import
urllib2
,
urllib
import
urllib2
,
urllib
import
urlparse
import
urlparse
from
cgi
import
parse_header
from
cgi
import
parse_header
...
@@ -48,67 +47,9 @@ from AccessControl import Unauthorized
...
@@ -48,67 +47,9 @@ from AccessControl import Unauthorized
from
DateTime
import
DateTime
from
DateTime
import
DateTime
import
warnings
import
warnings
# Install openers
import
dircache
import
mimetypes
,
mimetools
from
email.utils
import
formatdate
class
DirectoryFileHandler
(
urllib2
.
FileHandler
):
"""
Extends the file handler to provide an HTML
representation of local directories.
"""
# Use local file or FTP depending on form of URL
def
file_open
(
self
,
req
):
url
=
req
.
get_selector
()
if
url
[:
2
]
==
'//'
and
url
[
2
:
3
]
!=
'/'
:
req
.
type
=
'ftp'
return
self
.
parent
.
open
(
req
)
else
:
return
self
.
open_local_file
(
req
)
# not entirely sure what the rules are here
def
open_local_file
(
self
,
req
):
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
localfile
=
urllib2
.
url2pathname
(
file
)
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
mimetools
.
Message
(
cStringIO
.
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
host
:
host
,
port
=
urllib
.
splitport
(
host
)
if
not
host
or
\
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
try
:
file_list
=
dircache
.
listdir
(
localfile
)
s
=
cStringIO
.
StringIO
()
s
.
write
(
'<html><head><base href="%s"/></head><body>'
%
(
'file:'
+
file
))
s
.
write
(
'<p>Directory Content:</p>'
)
for
f
in
file_list
:
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
urllib
.
quote
(
f
),
f
))
s
.
write
(
'</body></html>'
)
s
.
seek
(
0
)
headers
=
mimetools
.
Message
(
cStringIO
.
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
'text/html'
,
size
,
modified
)))
return
urllib2
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
except
OSError
:
return
urllib2
.
addinfourl
(
open
(
localfile
,
'rb'
),
headers
,
'file:'
+
file
)
raise
urllib2
.
URLError
(
'file not on local host'
)
opener
=
urllib2
.
build_opener
(
DirectoryFileHandler
)
urllib2
.
install_opener
(
opener
)
# Global parameters
# Global parameters
TEMP_NEW_OBJECT_KEY
=
'_v_new_object'
MAX_REPEAT
=
10
MAX_REPEAT
=
10
_marker
=
[]
# Create a new marker object.
class
ContributionTool
(
BaseTool
):
class
ContributionTool
(
BaseTool
):
"""
"""
ContributionTool provides an abstraction layer to unify the contribution
ContributionTool provides an abstraction layer to unify the contribution
...
@@ -254,7 +195,7 @@ class ContributionTool(BaseTool):
...
@@ -254,7 +195,7 @@ class ContributionTool(BaseTool):
filename
=
filename
,
content_type
=
content_type
)
filename
=
filename
,
content_type
=
content_type
)
if
not
(
container
is
None
or
container
.
isModuleType
()
or
if
not
(
container
is
None
or
container
.
isModuleType
()
or
container
.
getTypeInfo
().
allowType
(
portal_type
)):
container
.
getTypeInfo
().
allowType
(
portal_type
)):
portal_type
=
'Embedded File'
portal_type
=
'Embedded File'
if
container
is
None
:
if
container
is
None
:
# If the portal_type was provided, we can go faster
# If the portal_type was provided, we can go faster
...
@@ -410,6 +351,7 @@ class ContributionTool(BaseTool):
...
@@ -410,6 +351,7 @@ class ContributionTool(BaseTool):
return
self
.
getPropertyDictFromFilename
(
filename
)
return
self
.
getPropertyDictFromFilename
(
filename
)
# WebDAV virtual folder support
# WebDAV virtual folder support
# pylint: disable=arguments-differ,redefined-builtin
def
_setObject
(
self
,
id
,
ob
,
portal_type
=
None
,
user_login
=
None
,
def
_setObject
(
self
,
id
,
ob
,
portal_type
=
None
,
user_login
=
None
,
container
=
None
,
discover_metadata
=
True
,
filename
=
None
,
container
=
None
,
discover_metadata
=
True
,
filename
=
None
,
input_parameter_dict
=
None
):
input_parameter_dict
=
None
):
...
@@ -607,7 +549,7 @@ class ContributionTool(BaseTool):
...
@@ -607,7 +549,7 @@ class ContributionTool(BaseTool):
try
:
try
:
url
=
content
.
asURL
()
url
=
content
.
asURL
()
file_object
,
filename
,
content_type
=
self
.
_openURL
(
url
)
file_object
,
filename
,
content_type
=
self
.
_openURL
(
url
)
except
urllib2
.
URLError
,
error
:
except
urllib2
.
URLError
:
if
repeat
==
0
or
not
batch_mode
:
if
repeat
==
0
or
not
batch_mode
:
# XXX - Call the extendBadURLList method,--NOT Implemented--
# XXX - Call the extendBadURLList method,--NOT Implemented--
raise
raise
...
@@ -656,7 +598,7 @@ class ContributionTool(BaseTool):
...
@@ -656,7 +598,7 @@ class ContributionTool(BaseTool):
elif
document
.
getCrawlingDepth
()
>
0
:
elif
document
.
getCrawlingDepth
()
>
0
:
# If this is an index document, stop crawling if crawling_depth is 0
# If this is an index document, stop crawling if crawling_depth is 0
document
.
activate
().
crawlContent
()
document
.
activate
().
crawlContent
()
except
urllib2
.
HTTPError
,
error
:
except
urllib2
.
HTTPError
:
if
repeat
==
0
or
not
batch_mode
:
if
repeat
==
0
or
not
batch_mode
:
# here we must call the extendBadURLList method,--NOT Implemented--
# here we must call the extendBadURLList method,--NOT Implemented--
# which had to add this url to bad URL list, so next time we avoid
# which had to add this url to bad URL list, so next time we avoid
...
...
product/ERP5/bootstrap/erp5_core/ToolComponentTemplateItem/portal_components/tool.erp5.ContributionTool.xml
0 → 100644
View file @
decf8d39
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Tool Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
ContributionTool
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<string>
Products.ERP5.Tool.ContributionTool
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
tool.erp5.ContributionTool
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Tool Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
product/ERP5/bootstrap/erp5_core/bt/template_tool_component_id_list
View file @
decf8d39
...
@@ -2,6 +2,7 @@ tool.erp5.AcknowledgementTool
...
@@ -2,6 +2,7 @@ tool.erp5.AcknowledgementTool
tool.erp5.BuilderTool
tool.erp5.BuilderTool
tool.erp5.CallableTool
tool.erp5.CallableTool
tool.erp5.ContributionRegistryTool
tool.erp5.ContributionRegistryTool
tool.erp5.ContributionTool
tool.erp5.DeliveryTool
tool.erp5.DeliveryTool
tool.erp5.DiffTool
tool.erp5.DiffTool
tool.erp5.DomainTool
tool.erp5.DomainTool
...
...
product/ERP5Type/ZopePatch.py
View file @
decf8d39
...
@@ -91,6 +91,7 @@ from Products.ERP5Type.patches import MimetypesRegistry
...
@@ -91,6 +91,7 @@ from Products.ERP5Type.patches import MimetypesRegistry
from
Products.ERP5Type.patches
import
users
from
Products.ERP5Type.patches
import
users
from
Products.ERP5Type.patches
import
Publish
from
Products.ERP5Type.patches
import
Publish
from
Products.ERP5Type.patches
import
WSGITask
from
Products.ERP5Type.patches
import
WSGITask
from
Products.ERP5Type.patches
import
urllib_opener
# These symbols are required for backward compatibility
# These symbols are required for backward compatibility
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
from
Products.ERP5Type.patches.PropertyManager
import
ERP5PropertyManager
...
...
product/ERP5Type/patches/urllib_opener.py
0 → 100644
View file @
decf8d39
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2007 Nexedi SARL and Contributors. All Rights Reserved.
# Jean-Paul Smets <jp@nexedi.com>
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# 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 the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# Install openers
# -> testTemplateTool.TestTemplateTool.test_getBusinessTemplateUrl
import
urllib
import
urllib2
import
cStringIO
import
socket
import
os
import
dircache
import
mimetypes
,
mimetools
from
email.utils
import
formatdate
class
DirectoryFileHandler
(
urllib2
.
FileHandler
):
"""
Extends the file handler to provide an HTML
representation of local directories.
"""
# Use local file or FTP depending on form of URL
def
file_open
(
self
,
req
):
url
=
req
.
get_selector
()
if
url
[:
2
]
==
'//'
and
url
[
2
:
3
]
!=
'/'
:
req
.
type
=
'ftp'
return
self
.
parent
.
open
(
req
)
else
:
return
self
.
open_local_file
(
req
)
# not entirely sure what the rules are here
def
open_local_file
(
self
,
req
):
host
=
req
.
get_host
()
file
=
req
.
get_selector
()
localfile
=
urllib2
.
url2pathname
(
file
)
stats
=
os
.
stat
(
localfile
)
size
=
stats
.
st_size
modified
=
formatdate
(
stats
.
st_mtime
,
usegmt
=
True
)
mtype
=
mimetypes
.
guess_type
(
file
)[
0
]
headers
=
mimetools
.
Message
(
cStringIO
.
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
mtype
or
'text/plain'
,
size
,
modified
)))
if
host
:
host
,
port
=
urllib
.
splitport
(
host
)
if
not
host
or
\
(
not
port
and
socket
.
gethostbyname
(
host
)
in
self
.
get_names
()):
try
:
file_list
=
dircache
.
listdir
(
localfile
)
s
=
cStringIO
.
StringIO
()
s
.
write
(
'<html><head><base href="%s"/></head><body>'
%
(
'file:'
+
file
))
s
.
write
(
'<p>Directory Content:</p>'
)
for
f
in
file_list
:
s
.
write
(
'<p><a href="%s">%s</a></p>
\
n
'
%
(
urllib
.
quote
(
f
),
f
))
s
.
write
(
'</body></html>'
)
s
.
seek
(
0
)
headers
=
mimetools
.
Message
(
cStringIO
.
StringIO
(
'Content-type: %s
\
n
Content-length: %d
\
n
Last-modified: %s
\
n
'
%
(
'text/html'
,
size
,
modified
)))
return
urllib2
.
addinfourl
(
s
,
headers
,
'file:'
+
file
)
except
OSError
:
return
urllib2
.
addinfourl
(
open
(
localfile
,
'rb'
),
headers
,
'file:'
+
file
)
raise
urllib2
.
URLError
(
'file not on local host'
)
opener
=
urllib2
.
build_opener
(
DirectoryFileHandler
)
urllib2
.
install_opener
(
opener
)
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