Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
erp5_rtl_support
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
Romain Courteaud
erp5_rtl_support
Commits
5a7887b9
Commit
5a7887b9
authored
Mar 01, 2012
by
Arnaud Fontaine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move resetting of package to component_package as it has always should been there.
parent
8139fdd3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
30 deletions
+39
-30
product/ERP5/ERP5Site.py
product/ERP5/ERP5Site.py
+1
-1
product/ERP5Type/Tool/ComponentTool.py
product/ERP5Type/Tool/ComponentTool.py
+6
-23
product/ERP5Type/dynamic/component_package.py
product/ERP5Type/dynamic/component_package.py
+30
-4
product/ERP5Type/mixin/component.py
product/ERP5Type/mixin/component.py
+2
-2
No files found.
product/ERP5/ERP5Site.py
View file @
5a7887b9
...
...
@@ -348,7 +348,7 @@ class ERP5Site(FolderMixIn, CMFSite, CacheCookieMixin):
except
AttributeError
:
reset_portal_type
=
False
synchronizeDynamicModules
(
self
,
force
=
reset_portal_typ
e
)
synchronizeDynamicModules
(
self
,
force
=
Tru
e
)
return
self
def
manage_beforeDelete
(
self
,
item
,
container
):
...
...
product/ERP5Type/Tool/ComponentTool.py
View file @
5a7887b9
...
...
@@ -44,9 +44,9 @@ from zLOG import LOG, INFO, WARNING
last_sync
=
-
1
class
ComponentTool
(
BaseTool
):
"""
This tool provides methods to load the the different types of
components of the ERP5 framework: Document classes, interface
s,
mixin classes, fields,
accessors, etc.
This tool provides methods to load the the different types of
components of
the ERP5 framework: Document classes, interfaces, mixin classes, field
s,
accessors, etc.
"""
id
=
"portal_components"
meta_type
=
"ERP5 Component Tool"
...
...
@@ -55,22 +55,6 @@ class ComponentTool(BaseTool):
security
=
ClassSecurityInfo
()
security
.
declareObjectProtected
(
Permissions
.
AccessContentsInformation
)
def
_resetModule
(
self
,
module
):
for
name
,
klass
in
module
.
__dict__
.
items
():
if
not
(
name
[
0
]
!=
'_'
and
isinstance
(
klass
,
ModuleType
)):
continue
full_module_name
=
"%s.%s"
%
(
module
.
__name__
,
name
)
LOG
(
"ERP5Type.Tool.ComponentTool"
,
INFO
,
"Resetting "
+
full_module_name
)
if
name
.
endswith
(
'_version'
):
self
.
_resetModule
(
getattr
(
module
,
name
))
# The module must be deleted first
del
sys
.
modules
[
full_module_name
]
delattr
(
module
,
name
)
security
.
declareProtected
(
Permissions
.
ResetDynamicClasses
,
'reset'
)
def
reset
(
self
,
force
=
True
,
reset_portal_type
=
True
):
"""
...
...
@@ -103,16 +87,15 @@ class ComponentTool(BaseTool):
with
Base
.
aq_method_lock
:
for
content_type
in
allowed_content_type_list
:
modul
e_name
=
content_type
.
split
(
' '
)[
0
].
lower
()
packag
e_name
=
content_type
.
split
(
' '
)[
0
].
lower
()
try
:
module
=
getattr
(
erp5
.
component
,
modul
e_name
)
package
=
getattr
(
erp5
.
component
,
packag
e_name
)
# XXX-arnau: not everything is defined yet...
except
AttributeError
:
pass
else
:
module
.
_resetRegistry
()
self
.
_resetModule
(
module
)
package
.
reset
()
if
reset_portal_type
:
type_tool
.
resetDynamicDocumentsOnceAtTransactionBoundary
()
...
...
product/ERP5Type/dynamic/component_package.py
View file @
5a7887b9
...
...
@@ -35,7 +35,7 @@ import threading
from
Products.ERP5.ERP5Site
import
getSite
from
types
import
ModuleType
from
zLOG
import
LOG
,
INFO
from
zLOG
import
LOG
,
INFO
,
BLATHER
class
ComponentVersionPackage
(
ModuleType
):
"""
...
...
@@ -123,9 +123,6 @@ class ComponentDynamicPackage(ModuleType):
return
self
.
__registry_dict
def
_resetRegistry
(
self
):
self
.
__registry_dict
.
clear
()
def
find_module
(
self
,
fullname
,
path
=
None
):
# Ignore imports with a path which are filesystem-only and any
# absolute imports which does not start with this package prefix,
...
...
@@ -264,3 +261,32 @@ class ComponentDynamicPackage(ModuleType):
setattr
(
self
,
component_name
,
new_module
)
return
new_module
def
reset
(
self
,
sub_package
=
None
):
"""
Reset the content of the current package and its version package as well
recursively. This method must be called within a lock to avoid side
effects
"""
if
sub_package
is
None
:
# Clear the Component registry
self
.
__registry_dict
.
clear
()
package
=
self
else
:
package
=
sub_package
for
name
,
module
in
package
.
__dict__
.
items
():
if
name
[
0
]
==
'_'
or
not
isinstance
(
module
,
ModuleType
):
continue
# Reset the content of the version package before resetting it
elif
isinstance
(
module
,
ComponentVersionPackage
):
self
.
reset
(
sub_package
=
module
)
module_name
=
"%s.%s"
%
(
package
.
__name__
,
name
)
LOG
(
"ERP5Type.Tool.ComponentTool"
,
BLATHER
,
"Resetting "
+
module_name
)
# The module must be deleted first from sys.modules to avoid imports in
# the meantime
del
sys
.
modules
[
module_name
]
delattr
(
package
,
name
)
product/ERP5Type/mixin/component.py
View file @
5a7887b9
...
...
@@ -150,7 +150,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
_message_reference_not_set
=
"Reference must be set"
_message_invalid_reference
=
"Reference cannot end with '_version' or "
\
"start with '_' or be equal to find_module
or load_module
"
"start with '_' or be equal to find_module
, load_module or reset
"
_message_version_not_set
=
"Version must be set"
_message_invalid_version
=
"Version cannot start with '_'"
...
...
@@ -177,7 +177,7 @@ class ComponentMixin(PropertyRecordableMixin, Base):
elif
(
reference
.
endswith
(
'_version'
)
or
reference
[
0
]
==
'_'
or
reference
in
(
'find_module'
,
'load_module'
)):
reference
in
(
'find_module'
,
'load_module'
,
'reset'
)):
error_list
.
append
(
ConsistencyMessage
(
self
,
object_relative_url
,
...
...
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