diff --git a/gen/__init__.py b/gen/__init__.py index d9d7146..4cefd86 100644 --- a/gen/__init__.py +++ b/gen/__init__.py @@ -23,11 +23,11 @@ emptyTuple = () labelTypes = ('label', 'descr', 'help') def initMasterValue(v): - '''Standardizes p_v as a list.''' + '''Standardizes p_v as a list of strings.''' if not v: res = [] elif type(v) not in sequenceTypes: res = [v] else: res = v - return res + return [str(v) for v in res] # Descriptor classes used for refining descriptions of elements in types # (pages, groups,...) ---------------------------------------------------------- @@ -1809,6 +1809,43 @@ class Ref(Type): elif nbOfRefs > maxRef: return obj.translate('max_ref_violated') + def linkObject(self, obj, value, back=False): + '''This method links p_value (which can be a list of objects) to p_obj + through this Ref field.''' + # p_value can be a list of objects + if type(value) in sequenceTypes: + for v in value: self.linkObject(obj, v, back=back) + return + # Gets the list of referred objects (=list of uids), or create it. + obj = obj.o + refs = getattr(obj, self.name, None) + if refs == None: + refs = obj.getProductConfig().PersistentList() + setattr(obj, self.name, refs) + # Insert p_value into it. + uid = value.o.UID() + if uid not in refs: + refs.append(uid) + # Update the back reference + if not back: self.back.linkObject(value, obj, back=True) + + def unlinkObject(self, obj, value, back=False): + '''This method unlinks p_value (which can be a list of objects) from + p_obj through this Ref field.''' + # p_value can be a list of objects + if type(value) in sequenceTypes: + for v in value: self.unlinkObject(obj, v, back=back) + return + obj = obj.o + refs = getattr(obj, self.name, None) + if not refs: return + # Unlink p_value + uid = value.o.UID() + if uid in refs: + refs.remove(uid) + # Update the back reference + if not back: self.back.unlinkObject(value, obj, back=True) + def store(self, obj, value): '''Stores on p_obj, the p_value, which can be: * None; @@ -1817,25 +1854,31 @@ class Ref(Type): of UIDs come from Ref fields with link:True edited through the web; * a Zope object; * a Appy object; - * a list of Appy or Zope objects. - ''' - # Standardize p_value into a list of uids - uids = value - if not uids: uids = [] - if type(uids) not in sequenceTypes: uids = [uids] - for i in range(len(uids)): - if not isinstance(uids[i], basestring): - # Get the UID from the Zope or Appy object - uids[i] = uids[i].o.UID() - # Update the list of referred uids. + * a list of Appy or Zope objects.''' + # Standardize p_value into a list of Zope objects + objects = value + if not objects: objects = [] + if type(objects) not in sequenceTypes: objects = [objects] + tool = obj.getTool() + for i in range(len(objects)): + if isinstance(objects[i], basestring): + # We have a UID here + objects[i] = tool.getObject(objects[i]) + else: + # Be sure to have a Zope object + objects[i] = objects[i].o + uids = [o.UID() for o in objects] + # Unlink objects that are not referred anymore refs = getattr(obj, self.name, None) - if refs == None: - refs = obj.getProductConfig().PersistentList(uids) - setattr(obj, self.name, refs) - else: - # Empty the list and fill it with uids - del refs[:] - for uid in uids: refs.append(uid) + if refs: + i = len(refs)-1 + while i >= 0: + if refs[i] not in uids: + # Object having this UID must unlink p_obj + self.back.unlinkObject(tool.getObject(refs[i]), obj) + i -= 1 + # Link new objects + self.linkObject(obj, objects) def clone(self, forTool=True): '''Produces a clone of myself.''' diff --git a/gen/plone25/mixins/__init__.py b/gen/plone25/mixins/__init__.py index fbb8f15..8421701 100644 --- a/gen/plone25/mixins/__init__.py +++ b/gen/plone25/mixins/__init__.py @@ -84,7 +84,7 @@ class BaseMixin: for field in self.getAllAppyTypes(): if field.type != 'Ref': continue for obj in field.getValue(self): - obj.unlink(field.back.name, self, back=True) + field.back.unlinkObject(obj, self, back=True) # Delete the object self.getParentNode().manage_delObjects([self.id]) diff --git a/gen/plone25/skin/appy.css b/gen/plone25/skin/appy.css index e02e318..db079b5 100644 --- a/gen/plone25/skin/appy.css +++ b/gen/plone25/skin/appy.css @@ -10,10 +10,12 @@ p { margin: 0;} acronym {cursor: help;} input[type=image] { border: 0; background: none; } input[type=checkbox] { border: 0; background: none; cursor: pointer;} +input[type=radio] { border: 0; background: none; cursor: pointer;} input[type=button] { border: 1px solid #cccccc; background-color: #f8f8f8; - cursor: pointer;} + cursor: pointer;} input[type=submit] { border: 1px solid #cccccc; background-color: #f8f8f8; cursor: pointer; } +input[type=password] { border: 1px solid #cccccc; background-color: #f8f8f8;} input[type=text] { border: 1px solid #cccccc; background-color: #f8f8f8; font-family: Lucida,Helvetica,Arial,sans-serif; margin-bottom: 1px} @@ -48,8 +50,8 @@ img {border: 0;} .phase { border-style: dashed; border-width: thin; padding: 0 0.6em 0 1em; } .content { padding: 14px 3px 9px 15px;} .grey { display: none; position: absolute; left: 0px; top: 0px; - width:100%; height:100%; background:grey; opacity:0.5; - -moz-opacity:0.5; -khtml-opacity:0.5; filter:alpha(Opacity=50);} + background:grey; opacity:0.5; -moz-opacity:0.5; -khtml-opacity:0.5; + filter:alpha(Opacity=50);} .popup { display: none; position: absolute; top: 30%; left: 35%; width: 350px; z-index : 100; background: white; padding: 8px; border: 1px solid grey; } diff --git a/gen/plone25/skin/appy.js b/gen/plone25/skin/appy.js index 5ad6094..ff0c6d7 100644 --- a/gen/plone25/skin/appy.js +++ b/gen/plone25/skin/appy.js @@ -248,7 +248,11 @@ function getSlaves(master) { // Gets all the slaves of master. allSlaves = document.getElementsByName('slave'); res = []; - slavePrefix = 'slave_' + master.attributes['name'].value + '_'; + masterName = master.attributes['name'].value; + if (master.type == 'checkbox') { + masterName = masterName.substr(0, masterName.length-8); + } + slavePrefix = 'slave_' + masterName + '_'; for (var i=0; i < slaves.length; i++){ cssClasses = slaves[i].className.split(' '); for (var j=0; j < cssClasses.length; j++) { @@ -381,13 +385,15 @@ function openPopup(popupId, msg) { // Open the popup var popup = document.getElementById(popupId); // Put it at the right place on the screen - var scrollTop = window.pageYOffset || document.documentElement.scrollTop || 0; + var scrollTop = document.body.scrollTop || window.pageYOffset || 0; popup.style.top = (scrollTop + 150) + 'px'; popup.style.display = "block"; // Show the greyed zone var greyed = document.getElementById('grey'); greyed.style.top = scrollTop + 'px'; greyed.style.display = "block"; + greyed.style.height = document.body.clientHeight; + greyed.style.width = document.body.clientWidth; } function closePopup(popupId) { diff --git a/gen/plone25/skin/import.pt b/gen/plone25/skin/import.pt index bb91d41..bef011e 100644 --- a/gen/plone25/skin/import.pt +++ b/gen/plone25/skin/import.pt @@ -75,7 +75,7 @@


- +
diff --git a/gen/plone25/skin/widgets/boolean.pt b/gen/plone25/skin/widgets/boolean.pt index 893c6d9..6b5be39 100644 --- a/gen/plone25/skin/widgets/boolean.pt +++ b/gen/plone25/skin/widgets/boolean.pt @@ -7,11 +7,10 @@ Edit macro for an Boolean. + class masterCss"/>
   - + - + - +
diff --git a/gen/plone25/skin/widgets/date.pt b/gen/plone25/skin/widgets/date.pt index b6a2499..15aca17 100644 --- a/gen/plone25/skin/widgets/date.pt +++ b/gen/plone25/skin/widgets/date.pt @@ -81,7 +81,7 @@ -
-
+
FromKeep the file untouched. - Delete the file. - @@ -42,7 +42,7 @@
Replace with a new file. - First row: the tabs.
- +
diff --git a/gen/plone25/skin/widgets/string.pt b/gen/plone25/skin/widgets/string.pt index a3d9344..929f52f 100644 --- a/gen/plone25/skin/widgets/string.pt +++ b/gen/plone25/skin/widgets/string.pt @@ -90,9 +90,9 @@ orName python: '%s_or' % operName; andName python: '%s_and' % operName;" condition="python: widget['multiplicity'][1]!=1"> - + - +
The list of values diff --git a/gen/plone25/wrappers/__init__.py b/gen/plone25/wrappers/__init__.py index a1590e1..4794d71 100644 --- a/gen/plone25/wrappers/__init__.py +++ b/gen/plone25/wrappers/__init__.py @@ -86,53 +86,15 @@ class AbstractWrapper(object): def getField(self, name): return self.o.getAppyType(name) - def link(self, fieldName, obj, back=False): + def link(self, fieldName, obj): '''This method links p_obj (which can be a list of objects) to this one - through reference field p_fieldName. As this method is recursive and - can be called to update the corresponding back reference, param - p_back is there, but, you, as Appy developer, should never set it - to True.''' - # p_objs can be a list of objects - if type(obj) in sequenceTypes: - for o in obj: self.link(fieldName, o, back=back) - return - # Gets the list of referred objects (=list of uids), or create it. - selfO = self.o - refs = getattr(selfO, fieldName, None) - if refs == None: - refs = selfO.getProductConfig().PersistentList() - setattr(selfO, fieldName, refs) - # Insert p_obj into it. - uid = obj.o.UID() - if uid not in refs: - refs.append(uid) - # Update the back reference - if not back: - backName = selfO.getAppyType(fieldName).back.attribute - obj.appy().link(backName, self, back=True) + through reference field p_fieldName.''' + return self.getField(fieldName).linkObject(self.o, obj) - def unlink(self, fieldName, obj, back=False): + def unlink(self, fieldName, obj): '''This method unlinks p_obj (which can be a list of objects) from this - one through reference field p_fieldName. As this method is recursive - and can be called to update the corresponding back reference, param - p_back is there, but, you, as Appy developer, should never set it - to True.''' - # p_objs can be a list of objects - if type(obj) in sequenceTypes: - for o in obj: self.unlink(fieldName, o, back=back) - return - # Get the list of referred objects - selfO = self.o - refs = getattr(selfO, fieldName, None) - if not refs: return - # Unlink the object - uid = obj.o.UID() - if uid in refs: - refs.remove(uid) - # Update the back reference - if not back: - backName = selfO.getAppyType(fieldName).back.attribute - obj.appy().unlink(backName, self, back=True) + one through reference field p_fieldName.''' + return self.getField(fieldName).unlinkObject(self.o, obj) def sort(self, fieldName, sortKey='title', reverse=False): '''Sorts referred elements linked to p_self via p_fieldName according @@ -194,8 +156,7 @@ class AbstractWrapper(object): setattr(appyObj, attrName, attrValue) if isField: # Link the object to this one - self.link(fieldName, ploneObj) - self.o.reindexObject() + appyType.linkObject(self.o, ploneObj) # Call custom initialization if externalData: param = externalData else: param = True