Ignore:
Timestamp:
Jan 5, 2010, 2:53:43 PM (13 years ago)
Author:
Ralph Meijer <ralphm@…>
Branch:
default
Message:

Move makeFields to wokkel.data_form, add form type checking.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wokkel/pubsub.py

    r63 r79  
    11# -*- test-case-name: wokkel.test.test_pubsub -*-
    22#
    3 # Copyright (c) 2003-2009 Ralph Meijer
     3# Copyright (c) 2003-2010 Ralph Meijer
    44# See LICENSE for details.
    55
     
    10131013
    10141014
    1015     def _makeFields(self, options, values):
    1016         fields = []
    1017         for name, value in values.iteritems():
    1018             if name not in options:
    1019                 continue
    1020 
    1021             option = {'var': name}
    1022             option.update(options[name])
    1023             if isinstance(value, list):
    1024                 option['values'] = value
    1025             else:
    1026                 option['value'] = value
    1027             fields.append(data_form.Field.fromDict(option))
    1028         return fields
    1029 
    1030 
    10311015    def _formFromConfiguration(self, resource, values):
    1032         options = resource.getConfigurationOptions()
    1033         fields = self._makeFields(options, values)
     1016        fieldDefs = resource.getConfigurationOptions()
    10341017        form = data_form.Form(formType="form",
    1035                               formNamespace=NS_PUBSUB_NODE_CONFIG,
    1036                               fields=fields)
    1037 
     1018                              formNamespace=NS_PUBSUB_NODE_CONFIG)
     1019        form.makeFields(values, fieldDefs)
    10381020        return form
    10391021
Note: See TracChangeset for help on using the changeset viewer.