Ignore:
Timestamp:
Nov 9, 2011, 6:44:36 PM (11 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Children:
155:8b2ed9549399, 159:bbb746f79718
Message:

Allow wokkel.data_form.Form to be used as a read-only dict.

In [1334124db2fd] wokkel.pubsub.PubSubRequest.options was changed to be a
Form instead of dictionary, which makes existing code using that field to be
incompatible.

To reduce the impact of that change, this change implements various methods in
wokkel.data_form.Form to emulate a read-only dictionary. It now maps the
name of each field to its value, similar to the dictionary returned from
getValues. The latter is now identical to dict(form).

  • * *

Address incompatible change concerning PubSubRequest?.options.

In changeset [1334124db2fd], PubSubRequest.options was changed to hold the
wokkel.data_form.Form that represents the data form sent in the original
request. This makes it easier to type check the form in a step separate from
parsing the request. However, this is an incompatible change.

To remedy this, we move the form to optionsForm and make options a property
that returns the values of the form.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/test/test_pubsub.py

    r97 r105  
    16181618
    16191619        request = pubsub.PubSubRequest.fromElement(parseXml(xml))
    1620         values = request.options.getValues()
     1620        values = request.options
    16211621        self.assertIn('pubsub#access_model', values)
    16221622        self.assertEqual(u'open', values['pubsub#access_model'])
     
    29142914        def configureSet(request):
    29152915            self.assertEquals(['pubsub#deliver_payloads'],
    2916                               request.options.fields.keys())
     2916                              request.options.keys())
    29172917
    29182918        self.resource.getConfigurationOptions = getConfigurationOptions
     
    37093709
    37103710        def setConfiguration(requestor, service, nodeIdentifier, options):
    3711             self.assertEquals({'pubsub#deliver_payloads': False,
    3712                                'pubsub#persist_items': True}, options)
    3713 
     3711            self.assertIn('pubsub#deliver_payloads', options)
     3712            self.assertFalse(options['pubsub#deliver_payloads'])
     3713            self.assertIn('pubsub#persist_items', options)
     3714            self.assertTrue(options['pubsub#persist_items'])
    37143715
    37153716        self.service.getConfigurationOptions = getConfigurationOptions
Note: See TracChangeset for help on using the changeset viewer.