Commit 94603fc9 authored by Andreas Jung's avatar Andreas Jung

- Collector #1058: Several fixes for PropertySheets when used

       outside ZClasses
parent 31af7fe6
......@@ -8,6 +8,9 @@ Zope Changes
Bugs fixed
- Collector #1058: Several fixes for PropertySheets when used
outside ZClasses
- Collector #1053: parseIndexRequest turned empty sequence of search
terms into unrestricted search.
......
......@@ -13,7 +13,7 @@
"""Property sheets"""
__version__='$Revision: 1.89 $'[11:-2]
__version__='$Revision: 1.90 $'[11:-2]
import time, App.Management, Globals
from webdav.WriteLockInterface import WriteLockInterface
......@@ -30,6 +30,11 @@ from AccessControl import getSecurityManager
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 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
)
# optionally to be overridden by derived classes
PropertySheetClass= PropertySheet
webdav =DAVProperties()
def _get_defaults(self):
return (self.webdav,)
......@@ -639,12 +647,14 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
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 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
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 @@ class PropertySheets(Traversable, Implicit, App.Management.Tabs):
if r is None:
pre='../'
else:
pre=r['URL']
pre=r['URLPATH0']
for i in (1,2):
l=pre.rfind('/')
if l >= 0:
......
......@@ -41,6 +41,7 @@ property values, edit the values and click "Save Changes".
</tr>
<dtml-in propertyMap mapping>
<dtml-let type="not _.has_key('type') and 'string' or type">
<tr>
<td align="left" valign="top" width="16">
<dtml-if "'d' in _['sequence-item'].get('mode', 'awd')">
......@@ -156,6 +157,7 @@ property values, edit the values and click &quot;Save Changes&quot;.
</div>
</td>
</tr>
</dtml-let>
</dtml-in>
<tr>
<td colspan="2">&nbsp;</td>
......
......@@ -4,12 +4,15 @@
<form action="&dtml-URL1;" method="post">
<table cellspacing="0" cellpadding="2" border="0">
<dtml-in items sort>
<dtml-with "_(REQUEST=REQUEST, item=_['sequence-item'].aq_base)" only>
<dtml-with "_(REQUEST=REQUEST, item=_['sequence-item'].aq_base, isDeletable=isDeletable)" only>
<dtml-with item>
<dtml-if id>
<tr>
<td align="left" valign="top">
<a href="&dtml-id;">&dtml-id; (&dtml-xml_namespace;)</a>
<dtml-if expr="isDeletable(id)"><input type=checkbox name="ids:list" value="&dtml-id;"></dtml-if>
</td>
<td align="left" valign="top">
<a href="&dtml-id;/manage">&dtml-id; <dtml-if xml_namespace>(<dtml-var xml_namespace>)</dtml-if></a>
<dtml-if locked_in_session>
<dtml-if modified_in_session>
<img src="&dtml-BASEPATH1;/p_/locked"
......@@ -25,18 +28,24 @@
</dtml-with>
</dtml-with>
</dtml-in>
</table>
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<td align="left" valign="top">
</td>
<td align="left" valign="top">
<input type="submit" name="manage_addPropertySheetForm:method"
class="form-element" value="Add">
<td colspan=2>
<input type="submit" name="manage_delPropertySheets:method"
class="form-element" value="Delete">
</td>
</tr>
</table>
<table cellpadding=5>
<tr>
<td><span class="form-label">Name:</span> <input name="id"></td>
<td><span class="form-label">Namespace:</span> <input name="ns"></td>
<td>
<input type="submit" name="manage_addPropertySheet:method"
class="form-element" value="Add">
</td>
</tr>
</table>
</form>
<dtml-var manage_page_footer>
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