Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Kirill Smelkov
Zope
Commits
a62db5fe
Commit
a62db5fe
authored
Mar 12, 2006
by
Chris Withers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move to python logging module.
parent
fd6f0a3f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
45 deletions
+44
-45
lib/python/OFS/Application.py
lib/python/OFS/Application.py
+44
-45
No files found.
lib/python/OFS/Application.py
View file @
a62db5fe
...
@@ -21,6 +21,7 @@ from StringIO import StringIO
...
@@ -21,6 +21,7 @@ from StringIO import StringIO
from
warnings
import
warn
from
warnings
import
warn
import
Globals
,
Products
,
App
.
Product
,
App
.
ProductRegistry
import
Globals
,
Products
,
App
.
Product
,
App
.
ProductRegistry
import
logging
import
transaction
import
transaction
from
AccessControl.User
import
UserFolder
from
AccessControl.User
import
UserFolder
from
Acquisition
import
aq_base
from
Acquisition
import
aq_base
...
@@ -32,7 +33,6 @@ from DateTime import DateTime
...
@@ -32,7 +33,6 @@ from DateTime import DateTime
from
HelpSys.HelpSys
import
HelpSys
from
HelpSys.HelpSys
import
HelpSys
from
webdav.NullResource
import
NullResource
from
webdav.NullResource
import
NullResource
from
zExceptions
import
Redirect
as
RedirectException
,
Forbidden
from
zExceptions
import
Redirect
as
RedirectException
,
Forbidden
from
zLOG
import
LOG
,
ERROR
,
WARNING
,
INFO
from
zope.interface
import
implements
from
zope.interface
import
implements
import
Folder
import
Folder
...
@@ -42,6 +42,7 @@ from FindSupport import FindSupport
...
@@ -42,6 +42,7 @@ from FindSupport import FindSupport
from
interfaces
import
IApplication
from
interfaces
import
IApplication
from
misc_
import
Misc_
from
misc_
import
Misc_
logger
=
logging
.
getLogger
(
'Zope'
)
class
Application
(
Globals
.
ApplicationDefaultPermissions
,
class
Application
(
Globals
.
ApplicationDefaultPermissions
,
ZDOM
.
Root
,
Folder
.
Folder
,
ZDOM
.
Root
,
Folder
.
Folder
,
...
@@ -231,9 +232,7 @@ class Application(Globals.ApplicationDefaultPermissions,
...
@@ -231,9 +232,7 @@ class Application(Globals.ApplicationDefaultPermissions,
ob
.
_register
()
ob
.
_register
()
result
=
1
result
=
1
if
not
rebuild
:
if
not
rebuild
:
LOG
(
'Zope'
,
INFO
,
logger
.
info
(
'Registered ZClass: %s'
,
ob
.
id
)
'Registered ZClass: %s'
%
ob
.
id
)
# Include subobjects.
# Include subobjects.
if
hasattr
(
base
,
'objectItems'
):
if
hasattr
(
base
,
'objectItems'
):
m
=
list
(
ob
.
objectItems
())
m
=
list
(
ob
.
objectItems
())
...
@@ -246,9 +245,9 @@ class Application(Globals.ApplicationDefaultPermissions,
...
@@ -246,9 +245,9 @@ class Application(Globals.ApplicationDefaultPermissions,
m
=
list
(
ps
.
methods
.
objectItems
())
m
=
list
(
ps
.
methods
.
objectItems
())
items
.
extend
(
m
)
items
.
extend
(
m
)
except
:
except
:
LOG
(
'Zope'
,
WARNING
,
logger
.
warning
(
'Broken objects exist in product %s.'
,
'Broken objects exist in product %s.'
%
product
.
id
,
product
.
id
,
error
=
sys
.
exc_info
()
)
exc_info
=
True
)
return
result
return
result
...
@@ -260,11 +259,11 @@ class Application(Globals.ApplicationDefaultPermissions,
...
@@ -260,11 +259,11 @@ class Application(Globals.ApplicationDefaultPermissions,
try
:
try
:
keys
=
list
(
self
.
_p_jar
.
root
()[
'ZGlobals'
].
keys
())
keys
=
list
(
self
.
_p_jar
.
root
()[
'ZGlobals'
].
keys
())
except
:
except
:
LOG
(
'Zope'
,
ERROR
,
logger
.
error
(
'A problem was found when checking the global product '
\
'A problem was found when checking the global product '
\
'registry. This is probably due to a Product being '
\
'registry. This is probably due to a Product being '
\
'uninstalled or renamed. The traceback follows.'
,
'uninstalled or renamed. The traceback follows.'
,
e
rror
=
sys
.
exc_info
()
)
e
xc_info
=
True
)
return
1
return
1
return
0
return
0
...
@@ -366,7 +365,7 @@ class AppInitializer:
...
@@ -366,7 +365,7 @@ class AppInitializer:
# tf is a MountPoint object. This means that the temp_folder
# tf is a MountPoint object. This means that the temp_folder
# couldn't be mounted properly (the meta_type would have been
# couldn't be mounted properly (the meta_type would have been
# the meta type of the container class otherwise). The
# the meta type of the container class otherwise). The
# MountPoint object writes a message to
zLOG
so we don't
# MountPoint object writes a message to
the log
so we don't
# need to.
# need to.
return
return
...
@@ -379,8 +378,9 @@ class AppInitializer:
...
@@ -379,8 +378,9 @@ class AppInitializer:
mount_paths
=
[
x
[
0
]
for
x
in
dbtab_config
.
listMountPaths
()
]
mount_paths
=
[
x
[
0
]
for
x
in
dbtab_config
.
listMountPaths
()
]
if
not
'/temp_folder'
in
mount_paths
:
if
not
'/temp_folder'
in
mount_paths
:
# we won't be able to create the mount point properly
# we won't be able to create the mount point properly
LOG
(
'Zope Default Object Creation'
,
ERROR
,
logger
.
error
((
(
'Could not initialze a Temporary Folder because '
'Zope Default Object Creation: '
'Could not initialze a Temporary Folder because '
'a database was not configured to be mounted at '
'a database was not configured to be mounted at '
'the /temp_folder mount point'
))
'the /temp_folder mount point'
))
return
return
...
@@ -390,10 +390,11 @@ class AppInitializer:
...
@@ -390,10 +390,11 @@ class AppInitializer:
self
.
commit
(
'Added temp_folder'
)
self
.
commit
(
'Added temp_folder'
)
tf
=
app
.
temp_folder
tf
=
app
.
temp_folder
except
:
except
:
LOG
(
'Zope Default Object Creation'
,
ERROR
,
logger
.
error
((
(
'Could not add a /temp_folder mount point due to an '
'Zope Default Object Creation: '
'Could not add a /temp_folder mount point due to an '
'error.'
),
'error.'
),
e
rror
=
sys
.
exc_info
()
)
e
xc_info
=
True
)
return
return
# Ensure that there is a transient object container in the temp folder
# Ensure that there is a transient object container in the temp folder
...
@@ -416,15 +417,15 @@ class AppInitializer:
...
@@ -416,15 +417,15 @@ class AppInitializer:
default_period_secs
)
default_period_secs
)
if
addnotify
and
app
.
unrestrictedTraverse
(
addnotify
,
None
)
is
None
:
if
addnotify
and
app
.
unrestrictedTraverse
(
addnotify
,
None
)
is
None
:
LOG
(
'Zope Default Object Creation'
,
WARNING
,
logger
.
warning
((
'Zope Default Object Creation: '
(
'failed to use nonexistent "%s" script as '
'failed to use nonexistent "%s" script as '
'session-add-notify-script-path'
%
addnotify
)
)
'session-add-notify-script-path'
),
addnotify
)
addnotify
=
None
addnotify
=
None
if
delnotify
and
app
.
unrestrictedTraverse
(
delnotify
,
None
)
is
None
:
if
delnotify
and
app
.
unrestrictedTraverse
(
delnotify
,
None
)
is
None
:
LOG
(
'Zope Default Object Creation'
,
WARNING
,
logger
.
warning
((
'Zope Default Object Creation: '
(
'failed to use nonexistent "%s" script as '
'failed to use nonexistent "%s" script as '
'session-delete-notify-script-path'
%
delnotify
)
)
'session-delete-notify-script-path'
),
delnotify
)
delnotify
=
None
delnotify
=
None
toc
=
TransientObjectContainer
(
toc
=
TransientObjectContainer
(
...
@@ -567,18 +568,16 @@ class AppInitializer:
...
@@ -567,18 +568,16 @@ class AppInitializer:
bad_things
=
0
bad_things
=
0
try
:
try
:
if
app
.
checkGlobalRegistry
():
if
app
.
checkGlobalRegistry
():
LOG
(
'Zope'
,
INFO
,
logger
.
info
(
'Beginning attempt to rebuild the global ZClass registry.'
)
'Beginning attempt to rebuild the global ZClass registry.'
)
app
.
fixupZClassDependencies
(
rebuild
=
1
)
app
.
fixupZClassDependencies
(
rebuild
=
1
)
did_fixups
=
1
did_fixups
=
1
LOG
(
'Zope'
,
INFO
,
logger
.
info
(
'The global ZClass registry has successfully been rebuilt.'
)
'The global ZClass registry has successfully been rebuilt.'
)
transaction
.
get
().
note
(
'Rebuilt global product registry'
)
transaction
.
get
().
note
(
'Rebuilt global product registry'
)
transaction
.
commit
()
transaction
.
commit
()
except
:
except
:
bad_things
=
1
bad_things
=
1
LOG
(
'Zope'
,
ERROR
,
'The attempt to rebuild the registry failed.'
,
logger
.
info
(
'The attempt to rebuild the registry failed.'
,
error
=
sys
.
exc_info
()
)
exc_info
=
True
)
transaction
.
abort
()
transaction
.
abort
()
# Now we need to see if any (disk-based) products were installed
# Now we need to see if any (disk-based) products were installed
...
@@ -594,18 +593,17 @@ class AppInitializer:
...
@@ -594,18 +593,17 @@ class AppInitializer:
# product was added or updated and we are not a ZEO client.
# product was added or updated and we are not a ZEO client.
if
getattr
(
Globals
,
'__disk_product_installed__'
,
None
):
if
getattr
(
Globals
,
'__disk_product_installed__'
,
None
):
try
:
try
:
LOG
(
'Zope'
,
INFO
,
logger
.
info
(
(
'New disk product detected, determining if we need '
(
'New disk product detected, determining if we need '
'to fix up any ZClasses.'
))
'to fix up any ZClasses.'
))
if
app
.
fixupZClassDependencies
():
if
app
.
fixupZClassDependencies
():
LOG
(
'Zope'
,
INFO
,
logger
.
info
(
'Repaired broken ZClass dependencies.'
)
'Repaired broken ZClass dependencies.'
)
self
.
commit
(
'Repaired broked ZClass dependencies'
)
self
.
commit
(
'Repaired broked ZClass dependencies'
)
except
:
except
:
LOG
(
'Zope'
,
ERROR
,
logger
.
error
(
(
'Attempt to fixup ZClass dependencies after '
(
'Attempt to fixup ZClass dependencies after '
'detecting an updated disk-based product failed.'
),
'detecting an updated disk-based product failed.'
),
e
rror
=
sys
.
exc_info
()
)
e
xc_info
=
True
)
transaction
.
abort
()
transaction
.
abort
()
def
install_products
(
self
):
def
install_products
(
self
):
...
@@ -682,10 +680,13 @@ def import_products():
...
@@ -682,10 +680,13 @@ def import_products():
for
priority
,
product_name
,
index
,
product_dir
in
products
:
for
priority
,
product_name
,
index
,
product_dir
in
products
:
if
done
.
has_key
(
product_name
):
if
done
.
has_key
(
product_name
):
LOG
(
'OFS.Application'
,
WARNING
,
'Duplicate Product name'
,
logger
.
warning
((
'OFS.Application: '
'Duplicate Product name:'
'After loading Product %s from %s,
\
n
'
'After loading Product %s from %s,
\
n
'
'I skipped the one in %s.
\
n
'
%
(
'I skipped the one in %s.
\
n
'
),
`product_name`
,
`done[product_name]`
,
`product_dir`
)
)
`product_name`
,
`done[product_name]`
,
`product_dir`
)
continue
continue
done
[
product_name
]
=
product_dir
done
[
product_name
]
=
product_dir
import_product
(
product_dir
,
product_name
,
raise_exc
=
debug_mode
)
import_product
(
product_dir
,
product_name
,
raise_exc
=
debug_mode
)
...
@@ -718,17 +719,15 @@ def import_product(product_dir, product_name, raise_exc=0, log_exc=1):
...
@@ -718,17 +719,15 @@ def import_product(product_dir, product_name, raise_exc=0, log_exc=1):
if
type
(
v
)
is
_st
and
have_module
(
v
):
v
=
modules
[
v
]
if
type
(
v
)
is
_st
and
have_module
(
v
):
v
=
modules
[
v
]
modules
[
k
]
=
v
modules
[
k
]
=
v
except
:
except
:
exc
=
sys
.
exc_info
()
if
log_exc
:
if
log_exc
:
LOG
(
'Zope'
,
ERROR
,
'Could not import %s'
%
pname
,
logger
.
error
(
'Could not import %s'
,
pname
,
exc_info
=
True
)
error
=
exc
)
f
=
StringIO
()
f
=
StringIO
()
traceback
.
print_exc
(
100
,
f
)
traceback
.
print_exc
(
100
,
f
)
f
=
f
.
getvalue
()
f
=
f
.
getvalue
()
try
:
modules
[
pname
].
__import_error__
=
f
try
:
modules
[
pname
].
__import_error__
=
f
except
:
pass
except
:
pass
if
raise_exc
:
if
raise_exc
:
raise
exc
[
0
],
exc
[
1
],
exc
[
2
]
raise
sys
.
exc_info
()
finally
:
finally
:
exc
=
None
exc
=
None
...
@@ -864,8 +863,8 @@ def install_product(app, product_dir, product_name, meta_types,
...
@@ -864,8 +863,8 @@ def install_product(app, product_dir, product_name, meta_types,
except
:
except
:
if
log_exc
:
if
log_exc
:
LOG
(
'Zope'
,
ERROR
,
'Couldn
\
'
t install %s'
%
product_name
,
logger
.
error
(
"Couldn't install %s"
,
product_name
,
error
=
sys
.
exc_info
()
)
exc_info
=
True
)
transaction
.
abort
()
transaction
.
abort
()
if
raise_exc
:
if
raise_exc
:
raise
raise
...
...
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