[Erp5-report] r21085 - in /erp5/trunk/products/ERP5: Document/ tests/
nobody at svn.erp5.org
nobody at svn.erp5.org
Thu May 22 23:36:41 CEST 2008
Author: yo
Date: Thu May 22 23:36:40 2008
New Revision: 21085
URL: http://svn.erp5.org?rev=21085&view=rev
Log:
Fix the export of site properties. Change the behavior of the installation to overwrite site properties, even if the same properties already exist.
Modified:
erp5/trunk/products/ERP5/Document/BusinessTemplate.py
erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
Modified: erp5/trunk/products/ERP5/Document/BusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/Document/BusinessTemplate.py?rev=21085&r1=21084&r2=21085&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/Document/BusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/Document/BusinessTemplate.py Thu May 22 23:36:40 2008
@@ -70,6 +70,7 @@
from OFS.ObjectManager import customImporters
from gzip import GzipFile
from xml.dom.minidom import parse
+from xml.sax.saxutils import escape
from Products.CMFCore.Expression import Expression
import tarfile
from urllib import quote, unquote
@@ -2510,20 +2511,28 @@
if action == 'nothing':
continue
dir, id = posixpath.split(path)
+ prop_type, property = self._objects[path]
if p.hasProperty(id):
- continue
- prop_type, property = self._objects[path]
- p._setProperty(id, property, type=prop_type)
+ if p.getPropertyType(id) != prop_type:
+ p._delProperty(id)
+ p._setProperty(id, property, type=prop_type)
+ else:
+ p._updateProperty(id, property)
+ else:
+ p._setProperty(id, property, type=prop_type)
else:
BaseTemplateItem.install(self, context, trashbin, **kw)
p = context.getPortalObject()
- for id,property in self._archive.keys():
+ for id, property in self._archive.keys():
property = self._archive[id]
if p.hasProperty(id):
- continue
- # Too much???
- #raise TemplateConflictError, 'the property %s already exists' % id
- p._setProperty(id, property['value'], type=property['type'])
+ if p.getPropertyType(id) != property['type']:
+ p._delProperty(id)
+ p._setProperty(id, property['value'], type=property['type'])
+ else:
+ p._updateProperty(id, property['value'])
+ else:
+ p._setProperty(id, property['value'], type=property['type'])
def uninstall(self, context, **kw):
p = context.getPortalObject()
@@ -2542,16 +2551,16 @@
xml_data = ''
prop_type, obj = self._objects[path]
xml_data += '\n <property>'
- xml_data += '\n <id>%s</id>' %(path,)
- xml_data += '\n <type>%s</type>' %(prop_type,)
+ xml_data += '\n <id>%s</id>' % escape(str(path))
+ xml_data += '\n <type>%s</type>' % escape(str(prop_type))
if prop_type in ('lines', 'tokens'):
xml_data += '\n <value>'
for item in obj:
if item != '':
- xml_data += '\n <item>%s</item>' %(item,)
+ xml_data += '\n <item>%s</item>' % escape(str(item))
xml_data += '\n </value>'
else:
- xml_data += '\n <value>%r</value>' %(('\n').join(obj),)
+ xml_data += '\n <value>%s</value>' % escape(str(obj))
xml_data += '\n </property>'
return xml_data
Modified: erp5/trunk/products/ERP5/tests/testBusinessTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testBusinessTemplate.py?rev=21085&r1=21084&r2=21085&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testBusinessTemplate.py (original)
+++ erp5/trunk/products/ERP5/tests/testBusinessTemplate.py Thu May 22 23:36:40 2008
@@ -5024,6 +5024,86 @@
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self, quiet=quiet)
+ def stepSetOldSitePropertyValue(self, sequence=None, sequence_list=None, **kw):
+ """Set the old value to a site property."""
+ sequence.set('site_property_value', 'old')
+
+ def stepSetNewSitePropertyValue(self, sequence=None, sequence_list=None, **kw):
+ """Set the new value to a site property."""
+ sequence.set('site_property_value', 'new')
+
+ def stepCreateSiteProperty(self, sequence=None, sequence_list=None, **kw):
+ """Create a site property."""
+ portal = self.getPortal()
+ portal._setProperty('a_property', sequence.get('site_property_value'))
+
+ def stepModifySiteProperty(self, sequence=None, sequence_list=None, **kw):
+ """Modify a site property."""
+ portal = self.getPortal()
+ portal._updateProperty('a_property', sequence.get('site_property_value'))
+
+ def stepCheckSiteProperty(self, sequence=None, sequence_list=None, **kw):
+ """Check a site property."""
+ portal = self.getPortal()
+ self.assertEquals(portal.getProperty('a_property'),
+ sequence.get('site_property_value'))
+
+ def stepCheckSitePropertyRemoved(self, sequence=None, sequence_list=None, **kw):
+ """Check if a site property is removed."""
+ portal = self.getPortal()
+ self.failIf(portal.hasProperty('a_property'))
+
+ def stepAddSitePropertyToBusinessTemplate(self, sequence=None, sequence_list=None,
+ **kw):
+ """Add a site property into a business template."""
+ bt = sequence.get('current_bt', None)
+ self.failUnless(bt is not None)
+ bt.edit(template_site_property_id_list=('a_property',))
+
+ def test_39_CheckSiteProperties(self, quiet=quiet, run=run_all_test):
+ if not run: return
+ if not quiet:
+ message = 'Test Site Properties'
+ ZopeTestCase._print('\n%s ' % message)
+ LOG('Testing... ', 0, message)
+ sequence_list = SequenceList()
+ sequence_string = '\
+ SetOldSitePropertyValue \
+ CreateSiteProperty \
+ CreateNewBusinessTemplate \
+ UseExportBusinessTemplate \
+ CheckModifiedBuildingState \
+ CheckNotInstalledInstallationState \
+ AddSitePropertyToBusinessTemplate \
+ BuildBusinessTemplate \
+ CheckBuiltBuildingState \
+ CheckNotInstalledInstallationState \
+ SaveBusinessTemplate \
+ CheckBuiltBuildingState \
+ CheckNotInstalledInstallationState \
+ RemoveBusinessTemplate \
+ RemoveAllTrashBins \
+ SetNewSitePropertyValue \
+ ModifySiteProperty \
+ ImportBusinessTemplate \
+ UseImportBusinessTemplate \
+ CheckBuiltBuildingState \
+ CheckNotInstalledInstallationState \
+ InstallBusinessTemplate \
+ Tic \
+ CheckInstalledInstallationState \
+ CheckBuiltBuildingState \
+ SetOldSitePropertyValue \
+ CheckSiteProperty \
+ UninstallBusinessTemplate \
+ CheckBuiltBuildingState \
+ CheckNotInstalledInstallationState \
+ SetOldSitePropertyValue \
+ CheckSitePropertyRemoved \
+ '
+ sequence_list.addSequenceString(sequence_string)
+ sequence_list.play(self, quiet=quiet)
+
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestBusinessTemplate))
More information about the Erp5-report
mailing list