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
6d8066d5
Commit
6d8066d5
authored
Apr 08, 2010
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PEP 8.
parent
7efbdc00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
128 additions
and
117 deletions
+128
-117
src/App/ApplicationManager.py
src/App/ApplicationManager.py
+128
-117
No files found.
src/App/ApplicationManager.py
View file @
6d8066d5
...
@@ -42,19 +42,22 @@ from zExceptions import Redirect
...
@@ -42,19 +42,22 @@ from zExceptions import Redirect
LOG
=
getLogger
(
'ApplicationManager'
)
LOG
=
getLogger
(
'ApplicationManager'
)
try
:
import
thread
try
:
except
:
get_ident
=
lambda
:
0
from
thread
import
get_ident
else
:
get_ident
=
thread
.
get_ident
except
ImportError
:
def
get_ident
():
return
0
class
DatabaseManager
(
Item
,
Implicit
):
class
DatabaseManager
(
Item
,
Implicit
):
"""Database management (legacy) """
"""Database management (legacy)
"""
manage
=
manage_main
=
DTMLFile
(
'dtml/dbMain'
,
globals
())
manage
=
manage_main
=
DTMLFile
(
'dtml/dbMain'
,
globals
())
manage_main
.
_setName
(
'manage_main'
)
manage_main
.
_setName
(
'manage_main'
)
id
=
'DatabaseManagement'
id
=
'DatabaseManagement'
name
=
title
=
'Database Management'
name
=
title
=
'Database Management'
meta_type
=
'Database Management'
meta_type
=
'Database Management'
icon
=
'p_/DatabaseManagement_icon'
icon
=
'p_/DatabaseManagement_icon'
manage_options
=
(
manage_options
=
(
(
(
...
@@ -89,7 +92,7 @@ class FakeConnection:
...
@@ -89,7 +92,7 @@ class FakeConnection:
class
DatabaseChooser
(
SimpleItem
):
class
DatabaseChooser
(
SimpleItem
):
"""
Lets you c
hoose which database to view
"""
C
hoose which database to view
"""
"""
meta_type
=
'Database Management'
meta_type
=
'Database Management'
name
=
title
=
'Database Management'
name
=
title
=
'Database Management'
...
@@ -140,17 +143,18 @@ InitializeClass(DatabaseChooser)
...
@@ -140,17 +143,18 @@ InitializeClass(DatabaseChooser)
# refcount snapshot info
# refcount snapshot info
_v_rcs
=
None
_v_rcs
=
None
_v_rst
=
None
_v_rst
=
None
class
DebugManager
(
Item
,
Implicit
):
class
DebugManager
(
Item
,
Implicit
):
"""Debug and profiling information"""
""" Debug and profiling information
manage
=
manage_main
=
DTMLFile
(
'dtml/debug'
,
globals
())
"""
manage
=
manage_main
=
DTMLFile
(
'dtml/debug'
,
globals
())
manage_main
.
_setName
(
'manage_main'
)
manage_main
.
_setName
(
'manage_main'
)
id
=
'DebugInfo'
id
=
'DebugInfo'
name
=
title
=
'Debug Information'
name
=
title
=
'Debug Information'
meta_type
=
name
meta_type
=
name
icon
=
'p_/DebugManager_icon'
icon
=
'p_/DebugManager_icon'
manage_options
=
(
manage_options
=
(
(
{
'label'
:
'Debugging Info'
,
'action'
:
'manage_main'
,
(
{
'label'
:
'Debugging Info'
,
'action'
:
'manage_main'
,
...
@@ -164,37 +168,36 @@ class DebugManager(Item, Implicit):
...
@@ -164,37 +168,36 @@ class DebugManager(Item, Implicit):
def
refcount
(
self
,
n
=
None
,
t
=
(
type
(
Implicit
),
)):
def
refcount
(
self
,
n
=
None
,
t
=
(
type
(
Implicit
),
)):
# return class reference info
# return class reference info
dict
=
{}
counts
=
{}
for
m
in
sys
.
modules
.
values
():
for
m
in
sys
.
modules
.
values
():
for
sym
in
dir
(
m
):
for
sym
in
dir
(
m
):
ob
=
getattr
(
m
,
sym
)
ob
=
getattr
(
m
,
sym
)
if
type
(
ob
)
in
t
:
if
type
(
ob
)
in
t
:
dict
[
ob
]
=
sys
.
getrefcount
(
ob
)
counts
[
ob
]
=
sys
.
getrefcount
(
ob
)
pairs
=
[]
pairs
=
[]
append
=
pairs
.
append
for
ob
,
v
in
counts
.
items
():
for
ob
,
v
in
dict
.
items
():
if
hasattr
(
ob
,
'__module__'
):
if
hasattr
(
ob
,
'__module__'
):
name
=
'%s.%s'
%
(
ob
.
__module__
,
ob
.
__name__
)
name
=
'%s.%s'
%
(
ob
.
__module__
,
ob
.
__name__
)
else
:
name
=
'%s'
%
ob
.
__name__
else
:
append
((
v
,
name
))
name
=
'%s'
%
ob
.
__name__
pairs
.
append
((
v
,
name
))
pairs
.
sort
()
pairs
.
sort
()
pairs
.
reverse
()
pairs
.
reverse
()
if
n
is
not
None
:
if
n
is
not
None
:
pairs
=
pairs
[:
n
]
pairs
=
pairs
[:
n
]
return
pairs
return
pairs
def
refdict
(
self
):
def
refdict
(
self
):
rc
=
self
.
refcount
()
counts
=
{}
dict
=
{}
for
v
,
n
in
self
.
refcount
():
for
v
,
n
in
rc
:
counts
[
n
]
=
v
dict
[
n
]
=
v
return
counts
return
dict
def
rcsnapshot
(
self
):
def
rcsnapshot
(
self
):
global
_v_rcs
global
_v_rcs
global
_v_rst
global
_v_rst
_v_rcs
=
self
.
refdict
()
_v_rcs
=
self
.
refdict
()
_v_rst
=
DateTime
()
_v_rst
=
DateTime
()
def
rcdate
(
self
):
def
rcdate
(
self
):
return
_v_rst
return
_v_rst
...
@@ -202,21 +205,23 @@ class DebugManager(Item, Implicit):
...
@@ -202,21 +205,23 @@ class DebugManager(Item, Implicit):
def
rcdeltas
(
self
):
def
rcdeltas
(
self
):
if
_v_rcs
is
None
:
if
_v_rcs
is
None
:
self
.
rcsnapshot
()
self
.
rcsnapshot
()
nc
=
self
.
refdict
()
nc
=
self
.
refdict
()
rc
=
_v_rcs
rc
=
_v_rcs
rd
=
[]
rd
=
[]
for
n
,
c
in
nc
.
items
():
for
n
,
c
in
nc
.
items
():
try
:
try
:
prev
=
rc
[
n
]
prev
=
rc
[
n
]
if
c
>
prev
:
if
c
>
prev
:
rd
.
append
(
(
c
-
prev
,
(
c
,
prev
,
n
))
)
rd
.
append
((
c
-
prev
,
(
c
,
prev
,
n
)))
except
:
pass
except
:
pass
rd
.
sort
()
rd
.
sort
()
rd
.
reverse
()
rd
.
reverse
()
return
map
(
lambda
n
:
{
'name'
:
n
[
1
][
2
],
return
[{
'name'
:
n
[
1
][
2
],
'delta'
:
n
[
0
],
'delta'
:
n
[
0
],
'pc'
:
n
[
1
][
1
],
'pc'
:
n
[
1
][
1
],
'rc'
:
n
[
1
][
0
]},
rd
)
'rc'
:
n
[
1
][
0
],
}
for
n
in
rd
]
def
dbconnections
(
self
):
def
dbconnections
(
self
):
import
Globals
# for data
import
Globals
# for data
...
@@ -227,21 +232,24 @@ class DebugManager(Item, Implicit):
...
@@ -227,21 +232,24 @@ class DebugManager(Item, Implicit):
manage_profile
=
DTMLFile
(
'dtml/profile'
,
globals
())
manage_profile
=
DTMLFile
(
'dtml/profile'
,
globals
())
def
manage_profile_stats
(
self
,
sort
=
'time'
,
limit
=
200
,
stripDirs
=
1
,
mode
=
'stats'
):
def
manage_profile_stats
(
self
,
sort
=
'time'
,
"""Return profile data if available"""
limit
=
200
,
stripDirs
=
1
,
mode
=
'stats'
):
stats
=
getattr
(
sys
,
'_ps_'
,
None
)
"""Return profile data if available
"""
stats
=
getattr
(
sys
,
'_ps_'
,
None
)
if
stats
is
None
:
if
stats
is
None
:
return
None
return
None
output
=
StringIO
()
output
=
StringIO
()
stdout
=
sys
.
stdout
stdout
=
sys
.
stdout
if
stripDirs
:
if
stripDirs
:
from
copy
import
copy
;
stats
=
copy
(
stats
)
from
copy
import
copy
stats
=
copy
(
stats
)
stats
.
strip_dirs
()
stats
.
strip_dirs
()
stats
.
sort_stats
(
sort
)
stats
.
sort_stats
(
sort
)
sys
.
stdout
=
output
sys
.
stdout
=
output
getattr
(
stats
,
'print_%s'
%
mode
)(
limit
)
getattr
(
stats
,
'print_%s'
%
mode
)(
limit
)
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
sys
.
stdout
=
stdout
sys
.
stdout
=
stdout
return
output
.
getvalue
()
return
output
.
getvalue
()
def
manage_getSysPath
(
self
):
def
manage_getSysPath
(
self
):
...
@@ -253,26 +261,17 @@ InitializeClass(DebugManager)
...
@@ -253,26 +261,17 @@ InitializeClass(DebugManager)
class
ApplicationManager
(
Folder
,
CacheManager
):
class
ApplicationManager
(
Folder
,
CacheManager
):
"""System management
"""
"""System management
"""
__roles__
=
(
'Manager'
,)
__roles__
=
(
'Manager'
,)
isPrincipiaFolderish
=
1
isPrincipiaFolderish
=
1
Database
=
DatabaseChooser
(
'Database'
)
#DatabaseManager()
Database
=
DatabaseChooser
(
'Database'
)
#DatabaseManager()
DebugInfo
=
DebugManager
()
DebugInfo
=
DebugManager
()
DavLocks
=
DavLockManager
()
DavLocks
=
DavLockManager
()
manage
=
manage_main
=
DTMLFile
(
'dtml/cpContents'
,
globals
())
manage
=
manage_main
=
DTMLFile
(
'dtml/cpContents'
,
globals
())
manage_main
.
_setName
(
'manage_main'
)
manage_main
.
_setName
(
'manage_main'
)
def
version_txt
(
self
):
if
not
hasattr
(
self
,
'_v_version_txt'
):
self
.
_v_version_txt
=
version_txt
()
return
self
.
_v_version_txt
def
sys_version
(
self
):
return
sys
.
version
def
sys_platform
(
self
):
return
sys
.
platform
_objects
=
(
_objects
=
(
{
'id'
:
'Database'
,
{
'id'
:
'Database'
,
'meta_type'
:
Database
.
meta_type
},
'meta_type'
:
Database
.
meta_type
},
...
@@ -290,23 +289,23 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -290,23 +289,23 @@ class ApplicationManager(Folder,CacheManager):
)
+
UndoSupport
.
manage_options
)
+
UndoSupport
.
manage_options
)
)
id
=
'Control_Panel'
id
=
'Control_Panel'
name
=
title
=
'Control Panel'
name
=
title
=
'Control Panel'
meta_type
=
'Control Panel'
meta_type
=
'Control Panel'
icon
=
'p_/ControlPanel_icon'
icon
=
'p_/ControlPanel_icon'
process_id
=
os
.
getpid
()
process_id
=
os
.
getpid
()
process_start
=
int
(
time
.
time
())
process_start
=
int
(
time
.
time
())
# Disable some inappropriate operations
# Disable some inappropriate operations
manage_addObject
=
None
manage_addObject
=
None
manage_delObjects
=
None
manage_delObjects
=
None
manage_addProperty
=
None
manage_addProperty
=
None
manage_editProperties
=
None
manage_editProperties
=
None
manage_delProperties
=
None
manage_delProperties
=
None
def
__init__
(
self
):
def
__init__
(
self
):
self
.
Products
=
ProductFolder
()
self
.
Products
=
ProductFolder
()
def
_canCopy
(
self
,
op
=
0
):
def
_canCopy
(
self
,
op
=
0
):
return
0
return
0
...
@@ -314,6 +313,18 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -314,6 +313,18 @@ class ApplicationManager(Folder,CacheManager):
def
_init
(
self
):
def
_init
(
self
):
pass
pass
def
version_txt
(
self
):
if
not
hasattr
(
self
,
'_v_version_txt'
):
self
.
_v_version_txt
=
version_txt
()
return
self
.
_v_version_txt
def
sys_version
(
self
):
return
sys
.
version
def
sys_platform
(
self
):
return
sys
.
platform
def
manage_app
(
self
,
URL2
):
def
manage_app
(
self
,
URL2
):
"""Return to the main management screen"""
"""Return to the main management screen"""
raise
Redirect
,
URL2
+
'/manage'
raise
Redirect
,
URL2
+
'/manage'
...
@@ -321,37 +332,40 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -321,37 +332,40 @@ class ApplicationManager(Folder,CacheManager):
def
process_time
(
self
,
_when
=
None
):
def
process_time
(
self
,
_when
=
None
):
if
_when
is
None
:
if
_when
is
None
:
_when
=
time
.
time
()
_when
=
time
.
time
()
s
=
int
(
_when
)
-
self
.
process_start
s
=
int
(
_when
)
-
self
.
process_start
d
=
int
(
s
/
86400
)
d
=
int
(
s
/
86400
)
s
=
s
-
(
d
*
86400
)
s
=
s
-
(
d
*
86400
)
h
=
int
(
s
/
3600
)
h
=
int
(
s
/
3600
)
s
=
s
-
(
h
*
3600
)
s
=
s
-
(
h
*
3600
)
m
=
int
(
s
/
60
)
m
=
int
(
s
/
60
)
s
=
s
-
(
m
*
60
)
s
=
s
-
(
m
*
60
)
d
=
d
and
(
'%d day%s'
%
(
d
,
(
d
!=
1
and
's'
or
''
)))
or
''
d
=
d
and
(
'%d day%s'
%
(
d
,
(
d
!=
1
and
's'
or
''
)))
or
''
h
=
h
and
(
'%d hour%s'
%
(
h
,
(
h
!=
1
and
's'
or
''
)))
or
''
h
=
h
and
(
'%d hour%s'
%
(
h
,
(
h
!=
1
and
's'
or
''
)))
or
''
m
=
m
and
(
'%d min'
%
m
)
or
''
m
=
m
and
(
'%d min'
%
m
)
or
''
s
=
'%d sec'
%
s
s
=
'%d sec'
%
s
return
'%s %s %s %s'
%
(
d
,
h
,
m
,
s
)
return
'%s %s %s %s'
%
(
d
,
h
,
m
,
s
)
def
thread_get_ident
(
self
):
return
get_ident
()
def
thread_get_ident
(
self
):
return
get_ident
()
def
db_name
(
self
):
def
db_name
(
self
):
return
self
.
_p_jar
.
db
().
getName
()
return
self
.
_p_jar
.
db
().
getName
()
def
db_size
(
self
):
def
db_size
(
self
):
s
=
self
.
_p_jar
.
db
().
getSize
()
s
=
self
.
_p_jar
.
db
().
getSize
()
if
type
(
s
)
is
type
(
''
):
if
type
(
s
)
is
type
(
''
):
return
s
return
s
if
s
>=
1048576.0
:
return
'%.1fM'
%
(
s
/
1048576.0
)
if
s
>=
1048576.0
:
return
'%.1fM'
%
(
s
/
1048576.0
)
return
'%.1fK'
%
(
s
/
1024.0
)
return
'%.1fK'
%
(
s
/
1024.0
)
if
os
.
environ
.
has_key
(
'ZMANAGED'
):
if
os
.
environ
.
has_key
(
'ZMANAGED'
):
manage_restartable
=
1
manage_restartable
=
1
@
requestmethod
(
'POST'
)
@
requestmethod
(
'POST'
)
def
manage_restart
(
self
,
URL1
,
REQUEST
=
None
):
def
manage_restart
(
self
,
URL1
,
REQUEST
=
None
):
"""Shut down the application"""
""" Shut down the application for restart.
"""
try
:
try
:
user
=
'"%s"'
%
getSecurityManager
().
getUser
().
getUserName
()
user
=
'"%s"'
%
getSecurityManager
().
getUser
().
getUserName
()
except
:
except
:
...
@@ -386,41 +400,38 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -386,41 +400,38 @@ class ApplicationManager(Folder,CacheManager):
if
_when
is
None
:
if
_when
is
None
:
_when
=
time
.
time
()
_when
=
time
.
time
()
t
=
_when
-
(
days
*
86400
)
t
=
_when
-
(
days
*
86400
)
db
=
self
.
_p_jar
.
db
()
db
=
self
.
_p_jar
.
db
()
t
=
db
.
pack
(
t
)
t
=
db
.
pack
(
t
)
if
REQUEST
is
not
None
:
if
REQUEST
is
not
None
:
REQUEST
[
'RESPONSE'
].
redirect
(
REQUEST
[
'RESPONSE'
].
redirect
(
REQUEST
[
'URL1'
]
+
'/manage_workspace'
)
REQUEST
[
'URL1'
]
+
'/manage_workspace'
)
return
t
return
t
def
revert_points
(
self
):
return
()
def
revert_points
(
self
):
return
()
def
version_list
(
self
):
def
version_list
(
self
):
# Return a list of currently installed products/versions
# Return a list of currently installed products/versions
path_join
=
os
.
path
.
join
isdir
=
os
.
path
.
isdir
exists
=
os
.
path
.
exists
cfg
=
getConfiguration
()
cfg
=
getConfiguration
()
product_dir
=
path_
join
(
cfg
.
softwarehome
,
'Products'
)
product_dir
=
os
.
path
.
join
(
cfg
.
softwarehome
,
'Products'
)
product_names
=
os
.
listdir
(
product_dir
)
product_names
=
os
.
listdir
(
product_dir
)
product_names
.
sort
()
product_names
.
sort
()
info
=
[]
info
=
[]
for
product_name
in
product_names
:
for
product_name
in
product_names
:
package_dir
=
path_
join
(
product_dir
,
product_name
)
package_dir
=
os
.
path
.
join
(
product_dir
,
product_name
)
if
not
isdir
(
package_dir
):
if
not
os
.
path
.
isdir
(
package_dir
):
continue
continue
version_txt
=
None
version_txt
=
None
for
name
in
(
'VERSION.TXT'
,
'VERSION.txt'
,
'version.txt'
):
for
name
in
(
'VERSION.TXT'
,
'VERSION.txt'
,
'version.txt'
):
v
=
path_
join
(
package_dir
,
name
)
v
=
os
.
path
.
join
(
package_dir
,
name
)
if
exists
(
v
):
if
os
.
path
.
exists
(
v
):
version_txt
=
v
version_txt
=
v
break
break
if
version_txt
is
not
None
:
if
version_txt
is
not
None
:
file
=
open
(
version_txt
,
'r'
)
file
=
open
(
version_txt
,
'r'
)
data
=
file
.
readline
()
data
=
file
.
readline
()
file
.
close
()
file
.
close
()
info
.
append
(
data
.
strip
())
info
.
append
(
data
.
strip
())
return
info
return
info
...
@@ -460,19 +471,19 @@ class ApplicationManager(Folder,CacheManager):
...
@@ -460,19 +471,19 @@ class ApplicationManager(Folder,CacheManager):
introduced in 2.4.
introduced in 2.4.
"""
"""
meta_types
=
map
(
lambda
x
:
x
.
get
(
'meta_type'
,
None
)
,
self
.
_objects
)
meta_types
=
map
(
lambda
x
:
x
.
get
(
'meta_type'
,
None
)
,
self
.
_objects
)
if
not
self
.
DavLocks
.
meta_type
in
meta_types
:
if
not
self
.
DavLocks
.
meta_type
in
meta_types
:
lst
=
list
(
self
.
_objects
)
lst
=
list
(
self
.
_objects
)
lst
.
append
(
{
'id'
:
'DavLocks'
,
\
lst
.
append
(
{
'id'
:
'DavLocks'
,
'meta_type'
:
self
.
DavLocks
.
meta_type
})
'meta_type'
:
self
.
DavLocks
.
meta_type
})
self
.
_objects
=
tuple
(
lst
)
self
.
_objects
=
tuple
(
lst
)
return
Folder
.
objectIds
(
self
,
spec
)
return
Folder
.
objectIds
(
self
,
spec
)
class
AltDatabaseManager
(
DatabaseManager
,
CacheManager
):
class
AltDatabaseManager
(
DatabaseManager
,
CacheManager
):
"""Database management DBTab-style
"""
Database management DBTab-style
"""
"""
db_name
=
ApplicationManager
.
db_name
.
im_func
db_name
=
ApplicationManager
.
db_name
.
im_func
db_size
=
ApplicationManager
.
db_size
.
im_func
db_size
=
ApplicationManager
.
db_size
.
im_func
...
...
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