Ignore:
Timestamp:
26 Dec 2014, 20:18:17 (10 years ago)
Author:
Henrik Bettermann
Message:

Rename ProductOptionEntry? ProductOption?.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r12310 r12327  
    213213# We have to keep the following two classes here. In products.interfaces they
    214214# will cause circular imports.
    215 class IProductOptionEntry(Interface):
     215class IProductOption(Interface):
    216216    """A product option entry.
    217217
     
    231231        )
    232232
    233 class IProductOptionEntryField(IObject):
     233class IProductOptionField(IObject):
    234234    """A zope.schema-like field for usage in interfaces.
    235235
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

    r12314 r12327  
    2222    ContextualDictSourceFactoryBase)
    2323from waeup.ikoba.interfaces import MessageFactory as _
    24 from waeup.ikoba.products.productoptions import ProductOptionEntryField
     24from waeup.ikoba.products.productoptions import ProductOptionField
    2525
    2626class ConCatSource(ContextualDictSourceFactoryBase):
     
    6666    options = schema.List(
    6767        title = _(u'Options/Fees'),
    68         value_type = ProductOptionEntryField(),
     68        value_type = ProductOptionField(),
    6969        required = False,
    7070        readonly = False,
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/productoptions.py

    r12323 r12327  
    2424from zope.schema.fieldproperty import FieldProperty
    2525from zope.schema import Object
    26 from waeup.ikoba.interfaces import IProductOptionEntry, IProductOptionEntryField
     26from waeup.ikoba.interfaces import IProductOption, IProductOptionField
    2727from waeup.ikoba.widgets.objectwidget import (
    2828    IkobaObjectWidget, IkobaObjectDisplayWidget
    2929    )
    3030
    31 class ProductOptionEntry(grok.Model):
     31class ProductOption(grok.Model):
    3232    """A product option entry contains a title, fee and currency.
    3333    """
    34     grok.implements(IProductOptionEntry)
    35     title = FieldProperty(IProductOptionEntry['title'])
    36     fee = FieldProperty(IProductOptionEntry['fee'])
    37     currency = FieldProperty(IProductOptionEntry['currency'])
     34    grok.implements(IProductOption)
     35    title = FieldProperty(IProductOption['title'])
     36    fee = FieldProperty(IProductOption['fee'])
     37    currency = FieldProperty(IProductOption['currency'])
    3838
    3939    def __init__(self, title=None, fee=None, currency=None):
    40         super(ProductOptionEntry, self).__init__()
     40        super(ProductOption, self).__init__()
    4141        if title is not None:
    4242            self.title = title
     
    5858    @classmethod
    5959    def from_string(cls, string):
    60         """Create new ProductOptionEntry instance based on `string`.
     60        """Create new ProductOption instance based on `string`.
    6161
    6262        The string is expected to be in format as delivered by
     
    6565        This is a classmethod. This means, you normally will call::
    6666
    67           ProductOptionEntry.from_string(mystring)
     67          ProductOption.from_string(mystring)
    6868
    69         i.e. use the `ProductOptionEntry` class, not an instance thereof.
     69        i.e. use the `ProductOption` class, not an instance thereof.
    7070        """
    7171        string = string.replace("u''", "None")
     
    7777        return cls(title, fee, currency)
    7878
    79 class ProductOptionEntryField(Object):
     79class ProductOptionField(Object):
    8080    """A zope.schema-like field for usage in interfaces.
    8181
     
    8484
    8585      class IMyInterface(Interface):
    86           my_option_entry = ProductOptionEntryField()
     86          my_option_entry = ProductOptionField()
    8787
    8888    Default widgets are registered to render product option entry fields.
    8989    """
    90     grok.implements(IProductOptionEntryField)
     90    grok.implements(IProductOptionField)
    9191
    9292    def __init__(self, **kw):
    93         super(ProductOptionEntryField, self).__init__(IProductOptionEntry, **kw)
     93        super(ProductOptionField, self).__init__(IProductOption, **kw)
    9494        return
    9595
    96 # register IkobaObjectWidgets as default widgets for IProductOptionEntryFields
    97 @grok.adapter(IProductOptionEntryField, IBrowserRequest)
     96# register IkobaObjectWidgets as default widgets for IProductOptionFields
     97@grok.adapter(IProductOptionField, IBrowserRequest)
    9898@grok.implementer(IInputWidget)
    99 def option_entry_input_widget(obj, req):
    100     return IkobaObjectWidget(obj, req, ProductOptionEntry)
     99def option_input_widget(obj, req):
     100    return IkobaObjectWidget(obj, req, ProductOption)
    101101
    102 # register a display widget for IProductOptionEntryFields
    103 @grok.adapter(IProductOptionEntryField, IBrowserRequest)
     102# register a display widget for IProductOptionFields
     103@grok.adapter(IProductOptionField, IBrowserRequest)
    104104@grok.implementer(IDisplayWidget)
    105 def option_entry_display_widget(obj, req):
    106     return IkobaObjectDisplayWidget(obj, req, ProductOptionEntry)
     105def option_display_widget(obj, req):
     106    return IkobaObjectDisplayWidget(obj, req, ProductOption)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_batching.py

    r12315 r12327  
    3838from waeup.ikoba.products.batching import ProductProcessor
    3939from waeup.ikoba.products.product import Product
    40 from waeup.ikoba.products.productoptions import ProductOptionEntry
     40from waeup.ikoba.products.productoptions import ProductOption
    4141from waeup.ikoba.testing import FunctionalLayer, FunctionalTestCase
    4242
     
    8383        product = Product()
    8484        product.product_id = u'LIC'
    85         options = ProductOptionEntry()
     85        options = ProductOption()
    8686        options.title = u'Base Fee'
    8787        options.fee = Decimal('800.6')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_browser.py

    r12318 r12327  
    4444from waeup.ikoba.tests.test_async import FunctionalAsyncTestCase
    4545from waeup.ikoba.browser.tests.test_pdf import samples_dir
    46 from waeup.ikoba.products.productoptions import ProductOptionEntry
     46from waeup.ikoba.products.productoptions import ProductOption
    4747
    4848def lookup_submit_value(name, value, browser):
     
    218218
    219219    def test_product_options(self):
    220         prodoptions = ProductOptionEntry()
     220        prodoptions = ProductOption()
    221221        prodoptions.title = u'My option'
    222222        prodoptions.fee = Decimal('99.9')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_productoptions.py

    r12309 r12327  
    55from zope.interface.verify import verifyObject, verifyClass
    66from zope.schema.interfaces import ConstraintNotSatisfied, WrongType
    7 from waeup.ikoba.interfaces import IProductOptionEntry, IProductOptionEntryField, IIkobaUtils
    8 from waeup.ikoba.products.productoptions import ProductOptionEntry, ProductOptionEntryField
     7from waeup.ikoba.interfaces import IProductOption, IProductOptionField, IIkobaUtils
     8from waeup.ikoba.products.productoptions import ProductOption, ProductOptionField
    99from waeup.ikoba.utils.utils import IkobaUtils
    1010
    11 class ProductOptionEntryTests(unittest.TestCase):
     11class ProductOptionTests(unittest.TestCase):
    1212
    1313    def setUp(self):
     
    2626    def test_ifaces(self):
    2727        # make sure we implement the promised interfaces.
    28         obj = ProductOptionEntry()
    29         verifyObject(IProductOptionEntry, obj)
    30         verifyClass(IProductOptionEntry, ProductOptionEntry)
     28        obj = ProductOption()
     29        verifyObject(IProductOption, obj)
     30        verifyClass(IProductOption, ProductOption)
    3131        return
    3232
    3333    def test_init(self):
    3434        # we can pass initial values
    35         item1 = ProductOptionEntry()
    36         item2 = ProductOptionEntry(
     35        item1 = ProductOption()
     36        item2 = ProductOption(
    3737            self.valid_title, self.valid_fee, self.valid_currency)
    3838        self.assertTrue(item1.title is None)
     
    4646    def test_illegal_value(self):
    4747        # we do not accept values which do not meet the interface
    48         item = ProductOptionEntry()
     48        item = ProductOption()
    4949        self.assertRaises(
    50             WrongType, ProductOptionEntry, 6, 500, 'invalid')
     50            WrongType, ProductOption, 6, 500, 'invalid')
    5151        return
    5252
    5353    def test_to_string(self):
    5454        # the string representation is handy for export
    55         item1 = ProductOptionEntry()
    56         item2 = ProductOptionEntry(
     55        item1 = ProductOption()
     56        item2 = ProductOption(
    5757            self.valid_title, self.valid_fee, self.valid_currency)
    5858        self.assertEqual(item1.to_string(), u"(None, None, None)")
     
    6565        myinput = u"(u'%s',u'%s',u'%s')" % (
    6666            self.valid_title, self.valid_fee, self.valid_currency)
    67         item1 = ProductOptionEntry.from_string(myinput)
    68         item2 = ProductOptionEntry.from_string(u"(u'', u'', u'')")
    69         item3 = ProductOptionEntry.from_string(u"(None, None, None)")
     67        item1 = ProductOption.from_string(myinput)
     68        item2 = ProductOption.from_string(u"(u'', u'', u'')")
     69        item3 = ProductOption.from_string(u"(None, None, None)")
    7070        self.assertEqual(item1.title, self.valid_title)
    7171        self.assertEqual(item1.fee, self.valid_fee)
     
    7979        return
    8080
    81 class ProductOptionEntryFieldTests(unittest.TestCase):
     81class ProductOptionFieldTests(unittest.TestCase):
    8282
    8383    def test_ifaces(self):
    8484        # make sure we implement the promised interfaces.
    85         obj = ProductOptionEntryField()
    86         verifyObject(IProductOptionEntryField, obj)
    87         verifyClass(IProductOptionEntryField, ProductOptionEntryField)
     85        obj = ProductOptionField()
     86        verifyObject(IProductOptionField, obj)
     87        verifyClass(IProductOptionField, ProductOptionField)
    8888        return
    8989
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/converters.py

    r12309 r12327  
    3030from zope.schema.interfaces import IList
    3131from waeup.ikoba.interfaces import (
    32     IObjectConverter, IProductOptionEntryField, IFieldConverter,
     32    IObjectConverter, IProductOptionField, IFieldConverter,
    3333    DELETION_MARKER, IGNORE_MARKER)
    3434from waeup.ikoba.schema.interfaces import IPhoneNumber
    35 from waeup.ikoba.products.productoptions import ProductOptionEntry
     35from waeup.ikoba.products.productoptions import ProductOption
    3636
    3737class ExtendedCheckBoxWidget(CheckBoxWidget):
     
    175175        return result
    176176
    177 class ProductOptionEntryConverter(grok.Adapter):
    178     grok.context(IProductOptionEntryField)
     177class ProductOptionConverter(grok.Adapter):
     178    grok.context(IProductOptionField)
    179179    grok.implements(IFieldConverter)
    180180
    181181    def request_data(self, name, value, schema_field, prefix='',
    182182                     mode='create'):
    183         """Turn CSV values into ProductOptionEntry-compatible form data.
     183        """Turn CSV values into ProductOption-compatible form data.
    184184
    185185        Expects as `value` a _string_ like ``(u'mytitle',
     
    194194        where the values are tokens from appropriate sources.
    195195
    196         Such dicts can be transformed into real ProductOptionEntry objects by
     196        Such dicts can be transformed into real ProductOption objects by
    197197        input widgets used in converters.
    198198        """
    199199        try:
    200             entry = ProductOptionEntry.from_string(value)
     200            entry = ProductOption.from_string(value)
    201201            title, fee, currency = entry.title, entry.fee, entry.currency
    202202        except:
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/tests/test_converters.py

    r12309 r12327  
    3838    SimpleIkobaVocabulary, IFieldConverter,
    3939    DELETION_MARKER, IGNORE_MARKER)
    40 from waeup.ikoba.products.productoptions import ProductOptionEntryField
     40from waeup.ikoba.products.productoptions import ProductOptionField
    4141from waeup.ikoba.utils.converters import (
    4242    IObjectConverter, IFieldConverter, DefaultFieldConverter,
    43     ListFieldConverter, PhoneNumberFieldConverter, ProductOptionEntryConverter,
     43    ListFieldConverter, PhoneNumberFieldConverter, ProductOptionConverter,
    4444    DefaultObjectConverter)
    4545from waeup.ikoba.utils.helpers import attrs_to_fields
     
    9494    options = schema.List(
    9595        title = u'Options',
    96         value_type = ProductOptionEntryField(),
     96        value_type = ProductOptionField(),
    9797        required = True,
    9898        default = [],
     
    137137        obj2 = ListFieldConverter(None)
    138138        obj3 = PhoneNumberFieldConverter(None)
    139         obj4 = ProductOptionEntryConverter(None)
     139        obj4 = ProductOptionConverter(None)
    140140        verify.verifyObject(IFieldConverter, obj1)
    141141        verify.verifyObject(IFieldConverter, obj2)
     
    145145        verify.verifyClass(IFieldConverter, ListFieldConverter)
    146146        verify.verifyClass(IFieldConverter, PhoneNumberFieldConverter)
    147         verify.verifyClass(IFieldConverter, ProductOptionEntryConverter)
     147        verify.verifyClass(IFieldConverter, ProductOptionConverter)
    148148        return
    149149
  • main/waeup.ikoba/trunk/src/waeup/ikoba/widgets/objectwidget.py

    r12316 r12327  
    8282
    8383    def _getView(self, request):
    84         if self.context.schema.__name__ == 'IProductOptionEntry':
     84        if self.context.schema.__name__ == 'IProductOption':
    8585            return IProductOptionWidgetDisplayView(self, request)
    8686        return IkobaObjectWidgetView(self, request)
Note: See TracChangeset for help on using the changeset viewer.