[CMF-checkins] SVN: CMF/branches/1.5/C - Fixed broken PUT handling for CMFCalendar Events

Jens Vagelpohl jens at dataflake.org
Mon Jan 22 13:24:23 EST 2007


Log message for revision 72178:
  - Fixed broken PUT handling for CMFCalendar Events
    (http://www.zope.org/Collectors/CMF/458)
  

Changed:
  U   CMF/branches/1.5/CHANGES.txt
  U   CMF/branches/1.5/CMFCalendar/Event.py
  U   CMF/branches/1.5/CMFCalendar/tests/test_Event.py

-=-
Modified: CMF/branches/1.5/CHANGES.txt
===================================================================
--- CMF/branches/1.5/CHANGES.txt	2007-01-22 17:03:36 UTC (rev 72177)
+++ CMF/branches/1.5/CHANGES.txt	2007-01-22 18:24:22 UTC (rev 72178)
@@ -2,6 +2,9 @@
 
   Bug Fixes
 
+    - Fixed broken PUT handling for CMFCalendar Events
+      (http://www.zope.org/Collectors/CMF/458)
+
     - CMFSetup.workflow: Split out subdirectory when exporting workflow
       scripts.
       (http://www.zope.org/Collectors/CMF/373)

Modified: CMF/branches/1.5/CMFCalendar/Event.py
===================================================================
--- CMF/branches/1.5/CMFCalendar/Event.py	2007-01-22 17:03:36 UTC (rev 72177)
+++ CMF/branches/1.5/CMFCalendar/Event.py	2007-01-22 18:24:22 UTC (rev 72178)
@@ -360,7 +360,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'],
@@ -372,14 +371,16 @@
     security.declarePublic( 'getMetadataHeaders' )
     def getMetadataHeaders(self):
         """Return 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
 
@@ -400,13 +401,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/branches/1.5/CMFCalendar/tests/test_Event.py
===================================================================
--- CMF/branches/1.5/CMFCalendar/tests/test_Event.py	2007-01-22 17:03:36 UTC (rev 72177)
+++ CMF/branches/1.5/CMFCalendar/tests/test_Event.py	2007-01-22 18:24:22 UTC (rev 72178)
@@ -121,7 +121,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):
@@ -144,8 +163,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 TestSuite((
         makeSuite(TestEvent),



More information about the CMF-checkins mailing list