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
d676a933
Commit
d676a933
authored
Nov 06, 1997
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decoupled Document from DT editing ui.
parent
85101020
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
109 additions
and
74 deletions
+109
-74
lib/python/OFS/Document.py
lib/python/OFS/Document.py
+49
-74
lib/python/OFS/documentEdit.dtml
lib/python/OFS/documentEdit.dtml
+60
-0
No files found.
lib/python/OFS/Document.py
View file @
d676a933
"""Document object"""
__version__
=
'$Revision: 1.
19
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
20
$'
[
11
:
-
2
]
from
Globals
import
HTML
from
Globals
import
HTMLFile
from
string
import
join
,
split
,
strip
,
rfind
from
Globals
import
HTML
,
HTMLFile
,
MessageDialog
from
string
import
join
,
split
,
strip
,
rfind
,
atoi
from
AccessControl.Role
import
RoleManager
import
regex
import
SimpleItem
import
SimpleItem
,
regex
class
Document
(
HTML
,
RoleManager
,
SimpleItem
.
Item_w__name__
):
"""A Document object"""
meta_type
=
'Document'
icon
=
'OFS/Document_icon.gif'
__state_names__
=
HTML
.
__state_names__
+
(
'title'
,
'__roles__'
)
_formhead
=
"""
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">%s</TD>
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="%s">
</TD>
</TR>
<TR>
<TD><STRONG>Access<BR>Control</STRONG></TD>
<TD>
<TABLE>
<TR>
<TD VALIGN="TOP">
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="E"%s>
Allow users with selected roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="A"%s>
Allow based on default roles
<BR>
<INPUT TYPE="RADIO" NAME="acl_type" VALUE="P"%s>
Allow all users
</TD>
<TD VALIGN="TOP">
<SELECT NAME="acl_roles:list" SIZE="3" MULTIPLE>
%s
</SELECT>
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>"""
def
document_template_form_header
(
self
):
try
:
return
self
.
_formhead
%
(
self
.
id
(),
self
.
title
,
self
.
aclEChecked
(),
self
.
aclAChecked
(),
self
.
aclPChecked
(),
join
(
self
.
selectedRoles
(),
'
\
n
'
)
)
except
:
import
sys
return
'%s %s'
%
(
sys
.
exc_type
,
sys
.
exc_value
)
class
Document
(
HTML
,
RoleManager
,
SimpleItem
.
Item_w__name__
):
"""Document object"""
meta_type
=
'Document'
icon
=
'OFS/Document_icon.gif'
__state_names__
=
HTML
.
__state_names__
+
(
'title'
,
'__roles__'
)
def
initvars
(
self
,
mapping
,
vars
):
"""Hook to override signature so we can detect whether we are
...
...
@@ -83,13 +30,6 @@ class Document(HTML, RoleManager, SimpleItem.Item_w__name__):
if
RESPONSE
is
None
:
return
r
return
decapitate
(
r
,
RESPONSE
)
def
manage_edit
(
self
,
data
,
title
,
acl_type
=
'A'
,
acl_roles
=
[],
REQUEST
=
None
):
"""Edit method"""
self
.
title
=
title
self
.
_setRoles
(
acl_type
,
acl_roles
)
REQUEST
[
'CANCEL_ACTION'
]
=
"%s/manage_main"
%
REQUEST
[
'URL2'
]
return
HTML
.
manage_edit
(
self
,
data
,
REQUEST
)
def
validate
(
self
,
inst
,
parent
,
name
,
value
,
md
):
if
hasattr
(
value
,
'__roles__'
):
roles
=
value
.
__roles__
...
...
@@ -102,18 +42,53 @@ class Document(HTML, RoleManager, SimpleItem.Item_w__name__):
try
:
roles
=
parent
.
aq_acquire
(
'__roles__'
)
except
AttributeError
:
return
0
else
:
return
0
if
roles
is
None
:
return
1
try
:
return
md
.
AUTHENTICATED_USER
.
hasRole
(
roles
)
except
AttributeError
:
return
0
manage_editForm
=
HTMLFile
(
'OFS/documentEdit'
)
manage
=
manage_editDocument
=
manage_editForm
def
manage_edit
(
self
,
data
,
title
,
acl_type
=
'A'
,
acl_roles
=
[],
SUBMIT
=
'Change'
,
dtpref_cols
=
'50'
,
dtpref_rows
=
'20'
,
REQUEST
=
None
):
"""Edit method"""
if
SUBMIT
==
'Smaller'
:
rows
=
atoi
(
dtpref_rows
)
-
5
cols
=
atoi
(
dtpref_cols
)
-
5
e
=
'Friday, 31-Dec-99 23:59:59 GMT'
resp
=
REQUEST
[
'RESPONSE'
]
resp
.
setCookie
(
'dtpref_rows'
,
str
(
rows
),
path
=
'/'
,
expires
=
e
)
resp
.
setCookie
(
'dtpref_cols'
,
str
(
cols
),
path
=
'/'
,
expires
=
e
)
return
self
.
manage_editForm
(
self
,
REQUEST
,
title
=
title
,
__str__
=
data
,
acl_type
=
acl_type
,
acl_roles
=
acl_roles
,
dtpref_cols
=
cols
,
dtpref_rows
=
rows
)
if
SUBMIT
==
'Bigger'
:
rows
=
atoi
(
dtpref_rows
)
+
5
cols
=
atoi
(
dtpref_cols
)
+
5
e
=
'Friday, 31-Dec-99 23:59:59 GMT'
resp
=
REQUEST
[
'RESPONSE'
]
resp
.
setCookie
(
'dtpref_rows'
,
str
(
rows
),
path
=
'/'
,
expires
=
e
)
resp
.
setCookie
(
'dtpref_cols'
,
str
(
cols
),
path
=
'/'
,
expires
=
e
)
return
self
.
manage_editForm
(
self
,
REQUEST
,
title
=
title
,
__str__
=
data
,
acl_type
=
acl_type
,
acl_roles
=
acl_roles
,
dtpref_cols
=
cols
,
dtpref_rows
=
rows
)
if
SUBMIT
==
'Cancel'
:
return
MessageDialog
(
title
=
'Changes Cancelled'
,
message
=
'Your changes have been discarded'
,
action
=
'%s/manage_main'
%
REQUEST
[
'URL2'
])
self
.
title
=
title
self
.
_setRoles
(
acl_type
,
acl_roles
)
self
.
munge
(
data
)
if
REQUEST
:
return
MessageDialog
(
title
=
'Change Successful'
,
message
=
'Your changes have been saved'
,
action
=
'%s/manage_main'
%
REQUEST
[
'URL2'
])
default_html
=
"""<!--#var standard_html_header-->
New Document
<H2><!--#var document_title--></H2>
<P>This is the <!--#var document_id--> Document in
the <!--#var title_or_id--> Folder.</P>
<!--#var standard_html_footer-->"""
...
...
lib/python/OFS/documentEdit.dtml
0 → 100644
View file @
d676a933
<HTML>
<HEAD>
<TITLE>Edit Document</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" LINK="#000099" VLINK="#555555">
<FORM ACTION="<!--#var PARENT_URL-->/manage_edit" METHOD="POST">
<H2>Edit Document</H2>
<TABLE CELLSPACING="2">
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<STRONG>Id</STRONG>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#var id-->
</TD>
</TR>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">
<EM><STRONG>Title</STRONG></EM>
</TD>
<TD ALIGN="LEFT" VALIGN="TOP">
<!--#if title-->
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="<!--#var title-->">
<!--#else title-->
<INPUT TYPE="TEXT" NAME="title" SIZE="40" VALUE="">
<!--#/if title-->
</TD>
</TR>
<!--#var smallRolesWidget-->
<TR>
<TD COLSPAN="2" ALIGN="CENTER">
<TEXTAREA NAME="data:text"
<!--#if dtpref_cols-->
COLS="<!--#var dtpref_cols-->"
<!--#else dtpref_cols-->
COLS="50"
<!--#/if dtpref_cols-->
<!--#if dtpref_rows-->
ROWS="<!--#var dtpref_rows-->"
<!--#else dtpref_rows-->
ROWS="20"
<!--#/if dtpref_rows-->><!--#var __str__--></TEXTAREA>
</TD>
</TR>
<TR>
<TD></TD>
<TD>
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Change">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Cancel">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Smaller">
<INPUT NAME=SUBMIT TYPE="SUBMIT" VALUE="Bigger">
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
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