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
Léo-Paul Géneau
erp5
Commits
5892dd0e
Commit
5892dd0e
authored
Nov 16, 2017
by
Ayush Tiwari
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQLCatalog: Cleanup manage_importProperties method
Its bad to access file from filesystem.
parent
e1fa7611
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
64 deletions
+0
-64
product/ZSQLCatalog/SQLCatalog.py
product/ZSQLCatalog/SQLCatalog.py
+0
-55
product/ZSQLCatalog/ZSQLCatalog.py
product/ZSQLCatalog/ZSQLCatalog.py
+0
-9
No files found.
product/ZSQLCatalog/SQLCatalog.py
View file @
5892dd0e
...
...
@@ -765,61 +765,6 @@ class Catalog(Folder,
'inline;filename=properties.xml'
)
return
f
.
getvalue
()
security
.
declareProtected
(
import_export_objects
,
'manage_importProperties'
)
def
manage_importProperties
(
self
,
file
):
"""
Import properties from an XML file.
"""
with
open
(
file
)
as
f
:
doc
=
parse
(
f
)
root
=
doc
.
documentElement
try
:
for
prop
in
root
.
getElementsByTagName
(
"property"
):
id
=
prop
.
getAttribute
(
"id"
)
type
=
prop
.
getAttribute
(
"type"
)
if
not
id
or
not
hasattr
(
self
,
id
):
raise
CatalogError
,
'unknown property id %r'
%
(
id
,)
if
type
not
in
(
'str'
,
'tuple'
):
raise
CatalogError
,
'unknown property type %r'
%
(
type
,)
if
type
==
'str'
:
value
=
''
for
text
in
prop
.
childNodes
:
if
text
.
nodeType
==
text
.
TEXT_NODE
:
value
=
str
(
text
.
data
)
break
else
:
value
=
[]
for
item
in
prop
.
getElementsByTagName
(
"item"
):
item_type
=
item
.
getAttribute
(
"type"
)
if
item_type
!=
'str'
:
raise
CatalogError
,
'unknown item type %r'
%
(
item_type
,)
for
text
in
item
.
childNodes
:
if
text
.
nodeType
==
text
.
TEXT_NODE
:
value
.
append
(
str
(
text
.
data
))
break
value
=
tuple
(
value
)
setattr
(
self
,
id
,
value
)
if
not
hasattr
(
self
,
'filter_dict'
):
self
.
filter_dict
=
PersistentMapping
()
for
filt
in
root
.
getElementsByTagName
(
"filter"
):
id
=
str
(
filt
.
getAttribute
(
"id"
))
expression
=
filt
.
getAttribute
(
"expression"
)
if
id
not
in
self
.
filter_dict
:
self
.
filter_dict
[
id
]
=
PersistentMapping
()
self
.
filter_dict
[
id
][
'filtered'
]
=
1
self
.
filter_dict
[
id
][
'type'
]
=
[]
if
expression
:
expr_instance
=
Expression
(
expression
)
self
.
filter_dict
[
id
][
'expression'
]
=
expression
self
.
filter_dict
[
id
][
'expression_instance'
]
=
expr_instance
else
:
self
.
filter_dict
[
id
][
'expression'
]
=
""
self
.
filter_dict
[
id
][
'expression_instance'
]
=
None
finally
:
doc
.
unlink
()
security
.
declareProtected
(
manage_zcatalog_entries
,
'manage_historyCompare'
)
def
manage_historyCompare
(
self
,
rev1
,
rev2
,
REQUEST
,
historyComparisonResults
=
''
):
...
...
product/ZSQLCatalog/ZSQLCatalog.py
View file @
5892dd0e
...
...
@@ -229,15 +229,6 @@ class ZCatalog(Folder, Persistent, Implicit):
if
catalog
is
not
None
:
return
catalog
.
manage_exportProperties
(
REQUEST
=
REQUEST
,
RESPONSE
=
RESPONSE
)
security
.
declareProtected
(
import_export_objects
,
'manage_catalogImportProperties'
)
def
manage_catalogImportProperties
(
self
,
file
,
sql_catalog_id
=
None
):
"""
Import properties from an XML file.
"""
catalog
=
self
.
getSQLCatalog
(
sql_catalog_id
)
if
catalog
is
not
None
:
return
catalog
.
manage_importProperties
(
file
)
def
__len__
(
self
):
catalog
=
self
.
getSQLCatalog
()
if
catalog
is
None
:
...
...
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