[CMF-checkins] SVN: CMF/trunk/CMFCalendar/ - Fixed broken PUT
handling for CMFCalendar Events
Jens Vagelpohl
jens at dataflake.org
Mon Jan 22 13:36:47 EST 2007
Log message for revision 72181:
- Fixed broken PUT handling for CMFCalendar Events
(http://www.zope.org/Collectors/CMF/458)
Changed:
U CMF/trunk/CMFCalendar/Event.py
U CMF/trunk/CMFCalendar/tests/test_Event.py
-=-
Modified: CMF/trunk/CMFCalendar/Event.py
===================================================================
--- CMF/trunk/CMFCalendar/Event.py 2007-01-22 18:36:05 UTC (rev 72180)
+++ CMF/trunk/CMFCalendar/Event.py 2007-01-22 18:36:46 UTC (rev 72181)
@@ -344,7 +344,6 @@
headers[key] = value
self._editMetadata(title=headers['Title'],
subject=headers['Subject'],
- description=headers['Description'],
contributors=headers['Contributors'],
effective_date=headers['Effective_date'],
expiration_date=headers['Expiration_date'],
@@ -357,14 +356,16 @@
def getMetadataHeaders(self):
""" Return metadata attributes in RFC-822-style header spec.
"""
- hdrlist = DefaultDublinCoreImpl.getMetadataHeaders(self)
- hdrlist.append( ('StartDate', self.start().strftime("%Y-%m-%d %H:%M:%S") ) )
- hdrlist.append( ('EndDate', self.end().strftime("%Y-%m-%d %H:%M:%S") ) )
- hdrlist.append( ('Location', self.location) )
- hdrlist.append( ('ContactName', self.contact_name) )
- hdrlist.append( ('ContactEmail', self.contact_email) )
- hdrlist.append( ('ContactPhone', self.contact_phone) )
- hdrlist.append( ('EventURL', self.event_url) )
+ fmt = '%Y-%m-%d %H:%M:%S'
+ hdrlist = [x for x in DefaultDublinCoreImpl.getMetadataHeaders(self)
+ if x[0] != 'Description']
+ hdrlist.append(('Startdate', self.start().strftime(fmt)))
+ hdrlist.append(('Enddate', self.end().strftime(fmt)))
+ hdrlist.append(('Location', self.location))
+ hdrlist.append(('Contactname', self.contact_name))
+ hdrlist.append(('Contactemail', self.contact_email))
+ hdrlist.append(('Contactphone', self.contact_phone))
+ hdrlist.append(('Eventurl', self.event_url))
return hdrlist
@@ -385,13 +386,14 @@
try:
headers, body, format = self.handleText(text=body)
self.setMetadata(headers)
- self.setStartDate(headers['StartDate'])
- self.setEndDate(headers['EndDate'])
+ self.setStartDate(headers['Startdate'])
+ self.setEndDate(headers['Enddate'])
self.edit( location=headers['Location']
- , contact_name=headers['ContactName']
- , contact_email=headers['ContactEmail']
- , contact_phone=headers['ContactPhone']
- , event_url=headers['EventURL']
+ , contact_name=headers['Contactname']
+ , contact_email=headers['Contactemail']
+ , contact_phone=headers['Contactphone']
+ , event_url=headers['Eventurl']
+ , description=body
)
except ResourceLockedError, msg:
Modified: CMF/trunk/CMFCalendar/tests/test_Event.py
===================================================================
--- CMF/trunk/CMFCalendar/tests/test_Event.py 2007-01-22 18:36:05 UTC (rev 72180)
+++ CMF/trunk/CMFCalendar/tests/test_Event.py 2007-01-22 18:36:46 UTC (rev 72181)
@@ -88,7 +88,26 @@
, startAMPM="AM"
)
+EVENT_TXT = """\
+Title: Test Event
+Subject: Foosubject
+Contributors: Jim
+Effective_date: 2002/01/01
+Expiration_date: 2009/12/31
+StartDate: 2006/02/23 18:00
+EndDate: 2006/02/23 23:00
+Location: Spuds and Suds, River Street, Anytown
+Language: French
+Rights: Anytown Gazetteer
+ContactName: Jim
+ContactEmail: jim at example.com
+ContactPhone: (888) 555-1212
+EventURL: http://www.example.com
+Creator: Jim
+Fundraiser for disabled goldfish
+"""
+
class EventPUTTests(RequestTest):
def _makeOne(self, id, *args, **kw):
@@ -111,8 +130,38 @@
self.assertEqual( d.ExpirationDate(), 'None' )
self.assertEqual( d.Language(), '' )
self.assertEqual( d.Rights(), '' )
+ self.assertEqual( d.location, '' )
+ self.assertEqual( d.contact_name, '' )
+ self.assertEqual( d.contact_email, '' )
+ self.assertEqual( d.contact_phone, '' )
+ self.assertEqual( d.event_url, '' )
+ def test_PutWithMetadata(self):
+ self.REQUEST['BODY'] = EVENT_TXT
+ self.REQUEST.environ['CONTENT_TYPE'] = 'text/html'
+ d = self._makeOne('foo')
+ d.PUT(self.REQUEST, self.RESPONSE)
+ self.assertEqual( d.Title(), 'Test Event' )
+ self.assertEqual( d.Format(), 'text/html' )
+ self.assertEqual( d.Description().strip()
+ , 'Fundraiser for disabled goldfish'
+ )
+ self.assertEqual( d.Subject(), ('Foosubject',) )
+ self.assertEqual( d.Contributors(), ('Jim',) )
+ self.assertEqual( d.EffectiveDate(), '2002-01-01 00:00:00' )
+ self.assertEqual( d.ExpirationDate(), '2009-12-31 00:00:00' )
+ self.assertEqual( d.Language(), 'French' )
+ self.assertEqual( d.Rights(), 'Anytown Gazetteer' )
+ self.assertEqual( d.location, 'Spuds and Suds, River Street, Anytown' )
+ self.assertEqual( d.contact_name, 'Jim' )
+ self.assertEqual( d.contact_email, 'jim at example.com' )
+ self.assertEqual( d.contact_phone, '(888) 555-1212' )
+ self.assertEqual( d.event_url, 'http://www.example.com' )
+ self.assertEqual( d.start(), DateTime('2006/02/23 18:00') )
+ self.assertEqual( d.end(), DateTime('2006/02/23 23:00') )
+
+
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(TestEvent),
More information about the CMF-checkins
mailing list