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
Levin Zimmermann
erp5
Commits
dd3afb14
Commit
dd3afb14
authored
Apr 25, 2022
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TODO
parent
376bc263
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
106 additions
and
133 deletions
+106
-133
product/ERP5Type/Accessor/Translation.py
product/ERP5Type/Accessor/Translation.py
+1
-1
product/ERP5Type/Accessor/TypeDefinition.py
product/ERP5Type/Accessor/TypeDefinition.py
+5
-1
product/ERP5Type/Accessor/WorkflowState.py
product/ERP5Type/Accessor/WorkflowState.py
+2
-2
product/PortalTransforms/data.py
product/PortalTransforms/data.py
+3
-3
product/PortalTransforms/libtransforms/utils.py
product/PortalTransforms/libtransforms/utils.py
+70
-68
product/TimerService/timerserver/TimerServer.py
product/TimerService/timerserver/TimerServer.py
+24
-43
product/TimerService/timerserver/component.xml
product/TimerService/timerserver/component.xml
+0
-14
product/ZSQLCatalog/SearchText/AdvancedSearchTextParser.py
product/ZSQLCatalog/SearchText/AdvancedSearchTextParser.py
+1
-1
No files found.
product/ERP5Type/Accessor/Translation.py
View file @
dd3afb14
...
@@ -85,7 +85,7 @@ class TranslatedPropertyGetter(BaseGetter):
...
@@ -85,7 +85,7 @@ class TranslatedPropertyGetter(BaseGetter):
localizer
=
instance
.
getPortalObject
().
Localizer
localizer
=
instance
.
getPortalObject
().
Localizer
message_catalog
=
getattr
(
localizer
,
domain
,
None
)
message_catalog
=
getattr
(
localizer
,
domain
,
None
)
if
message_catalog
is
not
None
:
if
message_catalog
is
not
None
:
return
message_catalog
.
gettext
(
unicode
(
value
,
'utf8'
),
lang
=
self
.
_language
).
encode
(
'utf8'
)
return
message_catalog
.
gettext
(
value
,
lang
=
self
.
_language
)
else
:
else
:
return
value
return
value
...
...
product/ERP5Type/Accessor/TypeDefinition.py
View file @
dd3afb14
...
@@ -98,8 +98,10 @@ def asString(value):
...
@@ -98,8 +98,10 @@ def asString(value):
if
value
is
None
:
if
value
is
None
:
result
=
''
result
=
''
else
:
else
:
if
isinstance
(
value
,
unicode
):
if
six
.
PY2
and
isinstance
(
value
,
unicode
):
result
=
value
.
encode
(
'utf-8'
)
result
=
value
.
encode
(
'utf-8'
)
elif
six
.
PY3
and
isinstance
(
value
,
bytes
):
result
=
value
.
decode
(
'utf-8'
)
else
:
else
:
result
=
str
(
value
)
result
=
str
(
value
)
except
TypeError
:
except
TypeError
:
...
@@ -109,6 +111,8 @@ def asString(value):
...
@@ -109,6 +111,8 @@ def asString(value):
def
asList
(
value
):
def
asList
(
value
):
"""
"""
Return the value as a list or a type-specific default value if it fails.
Return the value as a list or a type-specific default value if it fails.
XXX-zope4py3: bytes()?
"""
"""
if
isinstance
(
value
,
(
list
,
tuple
)):
if
isinstance
(
value
,
(
list
,
tuple
)):
result
=
list
(
value
)
result
=
list
(
value
)
...
...
product/ERP5Type/Accessor/WorkflowState.py
View file @
dd3afb14
...
@@ -96,7 +96,7 @@ class TranslatedGetter(Getter):
...
@@ -96,7 +96,7 @@ class TranslatedGetter(Getter):
state_id
=
wf
.
_getWorkflowStateOf
(
instance
,
id_only
=
1
)
state_id
=
wf
.
_getWorkflowStateOf
(
instance
,
id_only
=
1
)
warn
(
'Translated workflow state getters, such as %s are deprecated'
%
warn
(
'Translated workflow state getters, such as %s are deprecated'
%
self
.
_id
,
DeprecationWarning
)
self
.
_id
,
DeprecationWarning
)
return
portal
.
Localizer
.
erp5_ui
.
gettext
(
state_id
)
.
encode
(
'utf8'
)
return
portal
.
Localizer
.
erp5_ui
.
gettext
(
state_id
)
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
...
@@ -119,7 +119,7 @@ class TranslatedTitleGetter(TitleGetter):
...
@@ -119,7 +119,7 @@ class TranslatedTitleGetter(TitleGetter):
if
result
==
''
:
if
result
==
''
:
result
=
localizer
.
erp5_ui
.
gettext
(
state_title
,
result
=
localizer
.
erp5_ui
.
gettext
(
state_title
,
lang
=
selected_language
)
lang
=
selected_language
)
return
result
.
encode
(
'utf8'
)
return
result
psyco
.
bind
(
__call__
)
psyco
.
bind
(
__call__
)
...
...
product/PortalTransforms/data.py
View file @
dd3afb14
from
zope.interface
import
implementer
from
zope.interface
import
implementer
import
six
from
Products.PortalTransforms.interfaces
import
IDataStream
from
Products.PortalTransforms.interfaces
import
IDataStream
@
implementer
(
IDataStream
)
@
implementer
(
IDataStream
)
class
datastream
:
class
datastream
:
"""A transformation datastream packet"""
"""A transformation datastream packet"""
if
six
.
PY2
:
__slots__
=
(
'name'
,
'_data'
,
'_metadata'
)
__slots__
=
(
'name'
,
'_data'
,
'_metadata'
)
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
__name__
=
name
self
.
__name__
=
name
...
...
product/PortalTransforms/libtransforms/utils.py
View file @
dd3afb14
import
re
import
re
import
os
import
os
import
sys
import
sys
from
sgmllib
import
SGMLParser
,
SGMLParseError
# XXX-zope4py3: sgmllib removed from standard library in favor of
# html.parser.HTMLParser
#from sgmllib import SGMLParser, SGMLParseError
try
:
try
:
# Need to be imported before win32api to avoid dll loading
# Need to be imported before win32api to avoid dll loading
...
@@ -142,95 +144,95 @@ NASTY_TAGS = { 'script' : 1
...
@@ -142,95 +144,95 @@ NASTY_TAGS = { 'script' : 1
class
IllegalHTML
(
ValueError
):
class
IllegalHTML
(
ValueError
):
pass
pass
class
StrippingParser
(
SGMLParser
):
#
class StrippingParser( SGMLParser ):
""" Pass only allowed tags; raise exception for known-bad. """
#
""" Pass only allowed tags; raise exception for known-bad. """
from
htmlentitydef
s
import
entitydefs
# replace entitydefs from sgmllib
# from html.entitie
s import entitydefs # replace entitydefs from sgmllib
def
__init__
(
self
):
#
def __init__( self ):
SGMLParser
.
__init__
(
self
)
#
SGMLParser.__init__( self )
self
.
result
=
""
#
self.result = ""
def
handle_data
(
self
,
data
):
#
def handle_data( self, data ):
if
data
:
#
if data:
self
.
result
=
self
.
result
+
data
#
self.result = self.result + data
def
handle_charref
(
self
,
name
):
#
def handle_charref( self, name ):
self
.
result
=
"%s&#%s;"
%
(
self
.
result
,
name
)
#
self.result = "%s&#%s;" % ( self.result, name )
def
handle_entityref
(
self
,
name
):
#
def handle_entityref(self, name):
if
self
.
entitydefs
.
has_key
(
name
)
:
# if name in self.entitydefs
:
x
=
';'
#
x = ';'
else
:
#
else:
# this breaks unstandard entities that end with ';'
#
# this breaks unstandard entities that end with ';'
x
=
''
#
x = ''
self
.
result
=
"%s&%s%s"
%
(
self
.
result
,
name
,
x
)
#
self.result = "%s&%s%s" % (self.result, name, x)
def
unknown_starttag
(
self
,
tag
,
attrs
):
#
def unknown_starttag(self, tag, attrs):
""" Delete all tags except for legal ones.
#
""" Delete all tags except for legal ones.
"""
#
"""
if
VALID_TAGS
.
has_key
(
tag
)
:
# if tag in VALID_TAGS
:
self
.
result
=
self
.
result
+
'<'
+
tag
#
self.result = self.result + '<' + tag
for
k
,
v
in
attrs
:
#
for k, v in attrs:
if
k
.
lower
().
startswith
(
'on'
):
#
if k.lower().startswith( 'on' ):
raise
IllegalHTML
(
'Javascipt event "%s" not allowed.'
%
k
)
#
raise IllegalHTML('Javascipt event "%s" not allowed.' % k)
if
v
.
lower
().
startswith
(
'javascript:'
):
#
if v.lower().startswith( 'javascript:' ):
raise
IllegalHTML
(
'Javascipt URI "%s" not allowed.'
%
v
)
#
raise IllegalHTML('Javascipt URI "%s" not allowed.' % v)
self
.
result
=
'%s %s="%s"'
%
(
self
.
result
,
k
,
v
)
#
self.result = '%s %s="%s"' % (self.result, k, v)
endTag
=
'</%s>'
%
tag
#
endTag = '</%s>' % tag
if
VALID_TAGS
.
get
(
tag
):
#
if VALID_TAGS.get(tag):
self
.
result
=
self
.
result
+
'>'
#
self.result = self.result + '>'
else
:
#
else:
self
.
result
=
self
.
result
+
' />'
#
self.result = self.result + ' />'
elif
NASTY_TAGS
.
get
(
tag
):
#
elif NASTY_TAGS.get( tag ):
raise
IllegalHTML
(
'Dynamic tag "%s" not allowed.'
%
tag
)
#
raise IllegalHTML('Dynamic tag "%s" not allowed.' % tag)
else
:
#
else:
pass
# omit tag
#
pass # omit tag
def
unknown_endtag
(
self
,
tag
):
#
def unknown_endtag(self, tag):
if
VALID_TAGS
.
get
(
tag
):
#
if VALID_TAGS.get( tag ):
self
.
result
=
"%s</%s>"
%
(
self
.
result
,
tag
)
#
self.result = "%s</%s>" % (self.result, tag)
remTag
=
'</%s>'
%
tag
#
remTag = '</%s>' % tag
def
parse_declaration
(
self
,
i
):
#
def parse_declaration(self, i):
"""Fix handling of CDATA sections. Code borrowed from BeautifulSoup.
#
"""Fix handling of CDATA sections. Code borrowed from BeautifulSoup.
"""
#
"""
j
=
None
#
j = None
if
self
.
rawdata
[
i
:
i
+
9
]
==
'<![CDATA['
:
#
if self.rawdata[i:i+9] == '<![CDATA[':
k
=
self
.
rawdata
.
find
(
']]>'
,
i
)
#
k = self.rawdata.find(']]>', i)
if
k
==
-
1
:
#
if k == -1:
k
=
len
(
self
.
rawdata
)
#
k = len(self.rawdata)
data
=
self
.
rawdata
[
i
+
9
:
k
]
#
data = self.rawdata[i+9:k]
j
=
k
+
3
#
j = k+3
self
.
result
.
append
(
"<![CDATA[%s]]>"
%
data
)
#
self.result.append("<![CDATA[%s]]>" % data)
else
:
#
else:
try
:
#
try:
j
=
SGMLParser
.
parse_declaration
(
self
,
i
)
#
j = SGMLParser.parse_declaration(self, i)
except
SGMLParseError
:
#
except SGMLParseError:
toHandle
=
self
.
rawdata
[
i
:]
#
toHandle = self.rawdata[i:]
self
.
result
.
append
(
toHandle
)
#
self.result.append(toHandle)
j
=
i
+
len
(
toHandle
)
#
j = i + len(toHandle)
return
j
#
return j
def
scrubHTML
(
html
):
#
def scrubHTML( html ):
""" Strip illegal HTML tags from string text. """
#
""" Strip illegal HTML tags from string text. """
parser
=
StrippingParser
()
#
parser = StrippingParser()
parser
.
feed
(
html
)
#
parser.feed( html )
parser
.
close
()
#
parser.close()
return
parser
.
result
#
return parser.result
product/TimerService/timerserver/TimerServer.py
View file @
dd3afb14
...
@@ -26,49 +26,30 @@ class TimerServer(threading.Thread):
...
@@ -26,49 +26,30 @@ class TimerServer(threading.Thread):
interval
)
interval
)
def
run
(
self
):
def
run
(
self
):
try
:
import
Products.ERP5.bin.zopewsgi
zopewsgi
=
sys
.
modules
[
'Products.ERP5.bin.zopewsgi'
]
while
1
:
except
KeyError
:
time
.
sleep
(
5
)
# wait until the zhttp_server exist in socket_map
try
:
# because TimerService has to be started after the Zope HTTPServer
server
=
Products
.
ERP5
.
bin
.
zopewsgi
.
server
from
asyncore
import
socket_map
break
ip
=
port
=
''
except
AttributeError
:
while
1
:
pass
time
.
sleep
(
5
)
for
k
,
v
in
socket_map
.
items
():
ip
,
port
=
server
.
addr
if
hasattr
(
v
,
'addr'
):
start_response
=
lambda
*
_
:
None
# see Zope/lib/python/App/ApplicationManager.py: def getServers(self)
type
=
str
(
getattr
(
v
,
'__class__'
,
'unknown'
))
class
handle
(
object
):
if
type
==
'ZServer.HTTPServer.zhttp_server'
:
def
__init__
(
self
,
module_name
,
request
,
response
):
ip
,
port
=
v
.
addr
self
.
service
=
partial
(
Products
.
ERP5
.
bin
.
zopewsgi
.
publish_module
,
break
request
.
environ
,
if
port
:
start_response
,
break
_module_name
=
module_name
,
from
ZServer.PubCore
import
handle
_request
=
request
,
else
:
_response
=
response
)
while
1
:
server
.
add_task
(
self
)
time
.
sleep
(
5
)
try
:
def
cancel
(
self
):
server
=
zopewsgi
.
server
pass
break
except
AttributeError
:
pass
ip
,
port
=
server
.
addr
start_response
=
lambda
*
_
:
None
class
handle
(
object
):
def
__init__
(
self
,
module_name
,
request
,
response
):
self
.
service
=
partial
(
zopewsgi
.
publish_module
,
request
.
environ
,
start_response
,
_module_name
=
module_name
,
_request
=
request
,
_response
=
response
)
server
.
add_task
(
self
)
def
cancel
(
self
):
pass
if
ip
==
'0.0.0.0'
:
if
ip
==
'0.0.0.0'
:
ip
=
socket
.
gethostbyname
(
socket
.
gethostname
())
ip
=
socket
.
gethostbyname
(
socket
.
gethostname
())
...
...
product/TimerService/timerserver/component.xml
deleted
100644 → 0
View file @
376bc263
<component>
<import
package=
"ZServer"
/>
<sectiontype
name=
"timer-server"
datatype=
"Products.TimerService.timerserver.TimerServerFactory"
implements=
"ZServer.server"
>
<key
name=
"interval"
datatype=
"float"
default=
"600"
>
<description>
Interval in seconds. Supports fractions of a second.
</description>
</key>
</sectiontype>
</component>
product/ZSQLCatalog/SearchText/AdvancedSearchTextParser.py
View file @
dd3afb14
...
@@ -41,7 +41,7 @@ except ImportError:
...
@@ -41,7 +41,7 @@ except ImportError:
IColumnNode
=
None
IColumnNode
=
None
def
verifyClass
(
*
args
,
**
kw
):
def
verifyClass
(
*
args
,
**
kw
):
pass
pass
implements
=
verifyClass
implements
=
verifyClass
# XXX need to be reviewed as it is decorator now
@
implementer
(
INode
)
@
implementer
(
INode
)
class
Node
(
object
):
class
Node
(
object
):
...
...
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