[Zope-Checkins] CVS: Zope/lib/python/OFS - DTMLDocument.py:1.48.6.1
DTMLMethod.py:1.79.6.3 PropertySheets.py:1.87.6.3
Andreas Jung
andreas at andreas-jung.com
Mon Sep 29 08:12:08 EDT 2003
Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv2908/lib/python/OFS
Modified Files:
Tag: Zope-2_6-branch
DTMLDocument.py DTMLMethod.py PropertySheets.py
Log Message:
- Collector #1058: Several fixes for PropertySheets when used
outside ZClasses
=== Zope/lib/python/OFS/DTMLDocument.py 1.48 => 1.48.6.1 ===
--- Zope/lib/python/OFS/DTMLDocument.py:1.48 Wed Aug 14 17:42:56 2002
+++ Zope/lib/python/OFS/DTMLDocument.py Mon Sep 29 08:11:37 2003
@@ -55,7 +55,7 @@
),
)
- def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='50',
+ def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='100%',
dtpref_rows='20',REQUEST=None):
"""
Replaces a Documents contents with Data, Title with Title.
=== Zope/lib/python/OFS/DTMLMethod.py 1.79.6.2 => 1.79.6.3 ===
--- Zope/lib/python/OFS/DTMLMethod.py:1.79.6.2 Wed Sep 25 09:02:23 2002
+++ Zope/lib/python/OFS/DTMLMethod.py Mon Sep 29 08:11:37 2003
@@ -220,21 +220,19 @@
def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
dr,dc = self._size_changes[SUBMIT]
-
- rows=str(max(1,int(dtpref_rows)+dr))
-
- if dtpref_cols[-1]=='%':
- cols= str(min(100, max(25,int(dtpref_cols[:-1])+dc)))+'%'
+ rows = str(max(1, int(dtpref_rows) + dr))
+ cols = str(dtpref_cols)
+ if cols.endswith('%'):
+ cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
- cols=str(max(35,int(dtpref_cols)+dc))
-
- e=(DateTime('GMT') + 365).rfc822()
- 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__=self.quotedHTML(data),
- dtpref_cols=cols,dtpref_rows=rows)
+ cols = str(max(35, int(cols) + dc))
+ e = (DateTime("GMT") + 365).rfc822()
+ setCookie = REQUEST["RESPONSE"].setCookie
+ setCookie("dtpref_rows", rows, path='/', expires=e)
+ setCookie("dtpref_cols", cols, path='/', expires=e)
+ REQUEST.other.update({"dtpref_cols":cols, "dtpref_rows":rows})
+ return self.manage_main(self, REQUEST, title=title,
+ __str__=self.quotedHTML(data))
def manage_edit(self,data,title,SUBMIT='Change',dtpref_cols='100%',
dtpref_rows='20',REQUEST=None):
=== Zope/lib/python/OFS/PropertySheets.py 1.87.6.2 => 1.87.6.3 ===
--- Zope/lib/python/OFS/PropertySheets.py:1.87.6.2 Sat Jun 14 12:09:53 2003
+++ Zope/lib/python/OFS/PropertySheets.py Mon Sep 29 08:11:37 2003
@@ -30,6 +30,11 @@
from webdav.common import isDavCollection
from cgi import escape
+
+# DM: we would like to import this from somewhere
+BadRequestException= 'Bad Request'
+
+
class View(App.Management.Tabs, Base):
"""A view of an object, typically used for management purposes
@@ -600,6 +605,9 @@
)
+ # optionally to be overridden by derived classes
+ PropertySheetClass= PropertySheet
+
webdav =DAVProperties()
def _get_defaults(self):
return (self.webdav,)
@@ -639,12 +647,14 @@
return propset.__of__(self)
return default
- def manage_addPropertySheet(self, id, ns):
+ def manage_addPropertySheet(self, id, ns, REQUEST=None):
""" """
md={'xmlns':ns}
- ps=PropertySheet(id, md)
+ ps= self.PropertySheetClass(id, md)
self.addPropertySheet(ps)
- return 'OK'
+ if REQUEST is None: return ps
+ ps= self.get(id)
+ REQUEST.RESPONSE.redirect('%s/manage' % ps.absolute_url())
def addPropertySheet(self, propset):
propsets=self.aq_parent.__propsets__
@@ -658,6 +668,25 @@
result.append(propset)
self.aq_parent.__propsets__=tuple(result)
+ ## DM: deletion support
+ def isDeletable(self,name):
+ '''currently, we say that *name* is deletable when it is not a
+ default sheet. Later, we may further restrict deletability
+ based on an instance attribute.'''
+ ps= self.get(name)
+ if ps is None: return 0
+ if ps in self._get_defaults(): return 0
+ return 1
+
+ def manage_delPropertySheets(self, ids=(), REQUEST=None):
+ '''delete all sheets identified by *ids*.'''
+ for id in ids:
+ if not self.isDeletable(id):
+ raise BadRequestException, 'attempt to delete undeletable property sheet: ' + id
+ self.delPropertySheet(id)
+ if REQUEST is not None:
+ REQUEST.RESPONSE.redirect('%s/manage' % self.absolute_url())
+
def __len__(self):
return len(self.__propsets__())
@@ -677,7 +706,7 @@
if r is None:
pre='../'
else:
- pre=r['URL']
+ pre=r['URLPATH0']
for i in (1,2):
l=pre.rfind('/')
if l >= 0:
More information about the Zope-Checkins
mailing list