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
966fde8b
Commit
966fde8b
authored
Apr 05, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style fixes
parent
88792a03
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
23 deletions
+35
-23
src/App/Undo.py
src/App/Undo.py
+35
-23
No files found.
src/App/Undo.py
View file @
966fde8b
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
$Id$
$Id$
"""
"""
from
Acquisition
import
aq_base
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_inner
from
Acquisition
import
aq_parent
from
Acquisition
import
aq_parent
from
AccessControl
import
getSecurityManager
from
AccessControl
import
getSecurityManager
...
@@ -30,6 +29,7 @@ import transaction
...
@@ -30,6 +29,7 @@ import transaction
from
ZopeUndo.Prefix
import
Prefix
from
ZopeUndo.Prefix
import
Prefix
from
zope.interface
import
implements
from
zope.interface
import
implements
class
UndoSupport
(
ExtensionClass
.
Base
):
class
UndoSupport
(
ExtensionClass
.
Base
):
implements
(
IUndoSupport
)
implements
(
IUndoSupport
)
...
@@ -37,8 +37,8 @@ class UndoSupport(ExtensionClass.Base):
...
@@ -37,8 +37,8 @@ class UndoSupport(ExtensionClass.Base):
security
=
ClassSecurityInfo
()
security
=
ClassSecurityInfo
()
manage_options
=
(
manage_options
=
(
{
'label'
:
'Undo'
,
'action'
:
'manage_UndoForm'
,
{
'label'
:
'Undo'
,
'action'
:
'manage_UndoForm'
,
'help'
:
(
'OFSP'
,
'Undo.stx'
)},
'help'
:
(
'OFSP'
,
'Undo.stx'
)},
)
)
security
.
declareProtected
(
undo_changes
,
'manage_UndoForm'
)
security
.
declareProtected
(
undo_changes
,
'manage_UndoForm'
)
...
@@ -47,20 +47,25 @@ class UndoSupport(ExtensionClass.Base):
...
@@ -47,20 +47,25 @@ class UndoSupport(ExtensionClass.Base):
globals
(),
globals
(),
PrincipiaUndoBatchSize
=
20
,
PrincipiaUndoBatchSize
=
20
,
first_transaction
=
0
,
first_transaction
=
0
,
last_transaction
=
20
last_transaction
=
20
,
)
)
def
get_request_var_or_attr
(
self
,
name
,
default
):
def
get_request_var_or_attr
(
self
,
name
,
default
):
if
hasattr
(
self
,
'REQUEST'
):
if
hasattr
(
self
,
'REQUEST'
):
REQUEST
=
self
.
REQUEST
REQUEST
=
self
.
REQUEST
if
REQUEST
.
has_key
(
name
):
return
REQUEST
[
name
]
if
REQUEST
.
has_key
(
name
):
if
hasattr
(
self
,
name
):
v
=
getattr
(
self
,
name
)
return
REQUEST
[
name
]
else
:
v
=
default
if
hasattr
(
self
,
name
):
REQUEST
[
name
]
=
v
v
=
getattr
(
self
,
name
)
else
:
v
=
default
REQUEST
[
name
]
=
v
return
v
return
v
else
:
else
:
if
hasattr
(
self
,
name
):
v
=
getattr
(
self
,
name
)
if
hasattr
(
self
,
name
):
else
:
v
=
default
v
=
getattr
(
self
,
name
)
else
:
v
=
default
return
v
return
v
security
.
declareProtected
(
undo_changes
,
'undoable_transactions'
)
security
.
declareProtected
(
undo_changes
,
'undoable_transactions'
)
...
@@ -90,36 +95,38 @@ class UndoSupport(ExtensionClass.Base):
...
@@ -90,36 +95,38 @@ class UndoSupport(ExtensionClass.Base):
if
hasattr
(
user
,
'aq_parent'
):
if
hasattr
(
user
,
'aq_parent'
):
path
=
'/'
.
join
(
user
.
aq_parent
.
getPhysicalPath
()[
1
:
-
1
])
path
=
'/'
.
join
(
user
.
aq_parent
.
getPhysicalPath
()[
1
:
-
1
])
else
:
else
:
path
=
''
path
=
''
if
path
:
spec
[
'user_name'
]
=
Prefix
(
path
)
if
path
:
spec
[
'user_name'
]
=
Prefix
(
path
)
if
getattr
(
aq_parent
(
aq_inner
(
self
)),
'_p_jar'
,
None
)
==
self
.
_p_jar
:
if
getattr
(
aq_parent
(
aq_inner
(
self
)),
'_p_jar'
,
None
)
==
self
.
_p_jar
:
# We only want to undo things done here (and not in mounted
# We only want to undo things done here (and not in mounted
# databases)
# databases)
opath
=
'/'
.
join
(
self
.
getPhysicalPath
())
opath
=
'/'
.
join
(
self
.
getPhysicalPath
())
else
:
else
:
# Special case: at the root of a database,
# Special case: at the root of a database,
# allow undo of any path.
# allow undo of any path.
opath
=
None
opath
=
None
if
opath
:
spec
[
'description'
]
=
Prefix
(
opath
)
if
opath
:
spec
[
'description'
]
=
Prefix
(
opath
)
r
=
self
.
_p_jar
.
db
().
undoInfo
(
r
=
self
.
_p_jar
.
db
().
undoInfo
(
first_transaction
,
last_transaction
,
spec
)
first_transaction
,
last_transaction
,
spec
)
for
d
in
r
:
for
d
in
r
:
d
[
'time'
]
=
t
=
DateTime
(
d
[
'time'
])
d
[
'time'
]
=
t
=
DateTime
(
d
[
'time'
])
desc
=
d
[
'description'
]
desc
=
d
[
'description'
]
tid
=
d
[
'id'
]
tid
=
d
[
'id'
]
if
desc
:
if
desc
:
desc
=
desc
.
split
()
desc
=
desc
.
split
()
d1
=
desc
[
0
]
d1
=
desc
[
0
]
desc
=
''
.
join
(
desc
[
1
:])
desc
=
''
.
join
(
desc
[
1
:])
if
len
(
desc
)
>
60
:
desc
=
desc
[:
56
]
+
' ...'
if
len
(
desc
)
>
60
:
desc
=
desc
[:
56
]
+
' ...'
tid
=
"%s %s %s %s"
%
(
encode64
(
tid
),
t
,
d1
,
desc
)
tid
=
"%s %s %s %s"
%
(
encode64
(
tid
),
t
,
d1
,
desc
)
else
:
else
:
tid
=
"%s %s"
%
(
encode64
(
tid
),
t
)
tid
=
"%s %s"
%
(
encode64
(
tid
),
t
)
d
[
'id'
]
=
tid
d
[
'id'
]
=
tid
return
r
return
r
...
@@ -136,7 +143,8 @@ class UndoSupport(ExtensionClass.Base):
...
@@ -136,7 +143,8 @@ class UndoSupport(ExtensionClass.Base):
tid
=
decode64
(
tid
[
0
])
tid
=
decode64
(
tid
[
0
])
undo
(
tid
)
undo
(
tid
)
if
REQUEST
is
None
:
return
if
REQUEST
is
None
:
return
REQUEST
[
'RESPONSE'
].
redirect
(
"%s/manage_UndoForm"
%
REQUEST
[
'URL1'
])
REQUEST
[
'RESPONSE'
].
redirect
(
"%s/manage_UndoForm"
%
REQUEST
[
'URL1'
])
return
''
return
''
...
@@ -147,13 +155,17 @@ InitializeClass(UndoSupport)
...
@@ -147,13 +155,17 @@ InitializeClass(UndoSupport)
import
binascii
import
binascii
def
encode64
(
s
,
b2a
=
binascii
.
b2a_base64
):
def
encode64
(
s
,
b2a
=
binascii
.
b2a_base64
):
if
len
(
s
)
<
58
:
return
b2a
(
s
)
if
len
(
s
)
<
58
:
r
=
[];
a
=
r
.
append
return
b2a
(
s
)
r
=
[]
a
=
r
.
append
for
i
in
range
(
0
,
len
(
s
),
57
):
for
i
in
range
(
0
,
len
(
s
),
57
):
a
(
b2a
(
s
[
i
:
i
+
57
])[:
-
1
])
a
(
b2a
(
s
[
i
:
i
+
57
])[:
-
1
])
return
''
.
join
(
r
)
return
''
.
join
(
r
)
def
decode64
(
s
,
a2b
=
binascii
.
a2b_base64
):
def
decode64
(
s
,
a2b
=
binascii
.
a2b_base64
):
__traceback_info__
=
len
(
s
),
`s`
__traceback_info__
=
len
(
s
),
`s`
return
a2b
(
s
+
'
\
n
'
)
return
a2b
(
s
+
'
\
n
'
)
...
...
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