Commit 0a8597bc authored by Jim Fulton's avatar Jim Fulton

New permission machinery with new getstate.

New UI-resizing interface.
parent 66f54717
"""Document object""" """Document object"""
__version__='$Revision: 1.50 $'[11:-2] __version__='$Revision: 1.51 $'[11:-2]
from Globals import HTML, HTMLFile, MessageDialog from Globals import HTML, HTMLFile, MessageDialog
from string import join,split,strip,rfind,atoi,lower from string import join,split,strip,rfind,atoi,lower
...@@ -49,26 +49,21 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit, ...@@ -49,26 +49,21 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit,
('Change permissions', ['manage_access']), ('Change permissions', ['manage_access']),
('Change/upload data', ['manage_edit','manage_upload','PUT']), ('Change/upload data', ['manage_edit','manage_upload','PUT']),
('Change proxy roles', ['manage_proxyForm','manage_proxy']), ('Change proxy roles', ['manage_proxyForm','manage_proxy']),
('View', ['__call__',]), ('View', ['__call__', '']),
('Shared permission', ['',]),
) )
__state_names__=( _state_name={'raw':1, 'globals':1, '__name__':1, '_vars':1}.has_key
HTML.__state_names__+('title', '_proxy_roles')+
tuple(reduce(lambda a, b: def __getstate__(self):
a+b, r={}
map(lambda permission: state_name=self._state_name
map(lambda name: for k, v in self.__dict__.items():
name+'__roles__', if state_name(k) or k[-11:]=='_Permission' or k[-9:]=="__roles__":
permission[1] r[k]=v
),
__ac_permissions__ return r
)
))
)
__call____roles__='Manager', 'Shared'
def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw): def __call__(self, client=None, REQUEST={}, RESPONSE=None, **kw):
""" """ """ """
kw['document_id'] =self.id kw['document_id'] =self.id
...@@ -141,6 +136,28 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit, ...@@ -141,6 +136,28 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit,
manage=manage_main=manage_editDocument=manage_editForm manage=manage_main=manage_editDocument=manage_editForm
manage_proxyForm=HTMLFile('documentProxy', globals()) manage_proxyForm=HTMLFile('documentProxy', globals())
_size_changes={
'Bigger': (5,5),
'Smaller': (-5,-5),
'Narrower': (0,-5),
'Wider': (0,5),
'Taller': (5,0),
'Shorter': (-5,0),
}
def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
rows=max(1,atoi(dtpref_rows)+dr)
cols=max(40,atoi(dtpref_cols)+dc)
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_main(self,REQUEST,title=title,__str__=data,
dtpref_cols=cols,dtpref_rows=rows)
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50', def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
dtpref_rows='20',REQUEST=None): dtpref_rows='20',REQUEST=None):
""" """
...@@ -153,24 +170,9 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit, ...@@ -153,24 +170,9 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit,
the data gets checked for DTML errors and is saved. the data gets checked for DTML errors and is saved.
""" """
self._validateProxy(REQUEST) self._validateProxy(REQUEST)
if SUBMIT=='Smaller': if self._size_changes.has_key(SUBMIT):
rows=atoi(dtpref_rows)-5 return self._er(data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST)
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_main(self,REQUEST,title=title,__str__=data,
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_main(self,REQUEST,title=title,__str__=data,
dtpref_cols=cols,dtpref_rows=rows)
self.title=title self.title=title
self.munge(data) self.munge(data)
if REQUEST: return MessageDialog( if REQUEST: return MessageDialog(
...@@ -189,7 +191,6 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit, ...@@ -189,7 +191,6 @@ class Document(cDocumentTemplate.cDocument, HTML, Explicit,
message='Your changes have been saved', message='Your changes have been saved',
action ='manage_main') action ='manage_main')
PUT__roles__='Manager',
def PUT(self, BODY, REQUEST): def PUT(self, BODY, REQUEST):
""" """
replaces the contents of the document with the BODY of an HTTP PUT request. replaces the contents of the document with the BODY of an HTTP PUT request.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment