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
d702bf05
Commit
d702bf05
authored
Mar 01, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use slice notation to remove prefixes/suffixes properly rather than replace().
parent
4a1dbd67
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
product/ERP5/Document/BusinessTemplate.py
product/ERP5/Document/BusinessTemplate.py
+1
-1
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+8
-8
No files found.
product/ERP5/Document/BusinessTemplate.py
View file @
d702bf05
...
...
@@ -3829,7 +3829,7 @@ class DocumentTemplateItem(FilesystemToZodbTemplateItem):
# does not set _archive with portal_components/ like
# ObjectTemplateItem.__init__()
self
.
_archive
[
name
]
=
None
del
self
.
_archive
[
name
.
replace
(
'portal_components/'
,
''
)
]
del
self
.
_archive
[
name
[
len
(
'portal_components/'
):]
]
def
export
(
self
,
context
,
bta
,
**
kw
):
path
=
self
.
__class__
.
__name__
+
'/'
...
...
product/ERP5Type/dynamic/component_package.py
View file @
d702bf05
...
...
@@ -72,7 +72,7 @@ class ComponentDynamicPackage(ModuleType):
self
.
_namespace
=
namespace
self
.
_namespace_prefix
=
namespace
+
'.'
self
.
_portal_type
=
portal_type
self
.
__version_suffix_len
=
len
(
'_version'
)
self
.
_lock
=
threading
.
RLock
()
# Add this module to sys.path for future imports
...
...
@@ -135,11 +135,11 @@ class ComponentDynamicPackage(ModuleType):
# __import__ will first try a relative import, for example
# erp5.component.XXX.YYY.ZZZ where erp5.component.XXX.YYY is the current
# Component where an import is done
name
=
fullname
.
replace
(
self
.
_namespace_prefix
,
''
)
name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
if
'.'
in
name
:
try
:
version
,
name
=
name
.
split
(
'.'
)
version
=
version
.
replace
(
'_version'
,
''
)
version
=
version
[:
-
self
.
__version_suffix_len
]
except
ValueError
:
return
None
...
...
@@ -152,7 +152,7 @@ class ComponentDynamicPackage(ModuleType):
# wrongly considered as importable and thus the actual filesystem class
# ignored
elif
(
name
not
in
self
.
_registry_dict
and
name
.
replace
(
'_version'
,
''
)
not
in
site
.
getVersionPriorityList
()):
name
[:
-
self
.
__version_suffix_len
]
not
in
site
.
getVersionPriorityList
()):
return
None
return
self
...
...
@@ -176,18 +176,18 @@ class ComponentDynamicPackage(ModuleType):
properly in find_module().
"""
site
=
getSite
()
component_name
=
fullname
.
replace
(
self
.
_namespace_prefix
,
''
)
component_name
=
fullname
[
len
(
self
.
_namespace_prefix
):]
if
component_name
.
endswith
(
'_version'
):
version
=
component_name
.
replace
(
'_version'
,
''
)
version
=
component_name
[:
-
self
.
__version_suffix_len
]
return
(
version
in
site
.
getVersionPriorityList
()
and
self
.
_getVersionPackage
(
version
)
or
None
)
component_id_alias
=
None
version_package_name
=
component_name
.
replace
(
'_version'
,
''
)
version_package_name
=
component_name
[:
-
self
.
__version_suffix_len
]
if
'.'
in
component_name
:
try
:
version
,
component_name
=
component_name
.
split
(
'.'
)
version
=
version
.
replace
(
'_version'
,
''
)
version
=
version
[:
-
self
.
__version_suffix_len
]
except
ValueError
:
return
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