Changeset 190

Show
Ignore:
Timestamp:
08/28/07 19:14:26 (6 years ago)
Author:
bbangert
Message:

- Fixed bug in associable not properly picking out its own plural name when

none is provided. Added unit test for the bug.

Location:
elixir/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r147 r190  
    110.4.0 
     2- Fixed bug in associable not properly picking out its own plural name when 
     3  none is provided. Added unit test for the bug. 
    24- Added ext sub-package for additional Elixir statements. 
    35- Added ext.associable for generating polymorphic associations with Elixir 
  • elixir/trunk/elixir/ext/associable.py

    r172 r190  
    120120    interface_name = entity.table.name 
    121121    able_name = interface_name + 'able' 
    122     attr_name = "%s_rel" % interface_name 
     122     
     123    if plural_name: 
     124        attr_name = "%s_rel" % plural_name 
     125    else: 
     126        plural_name = interface_name 
     127        attr_name = "%s_rel" % interface_name 
    123128     
    124129    association_table = sa.Table("%s" % able_name, entity._descriptor.metadata, 
  • elixir/trunk/tests/test_associable.py

    r189 r190  
    1212    using_options(shortnames=True) 
    1313 
     14 
     15class Comment(Entity): 
     16    has_field('id', Integer, primary_key=True) 
     17    has_field('name', Unicode) 
     18    has_field('text', String) 
     19 
    1420is_addressable = associable(Address, 'addresses') 
     21is_commentable = associable(Comment, 'comments') 
    1522 
    1623class Person(Entity): 
     
    2027    using_options(shortnames=True) 
    2128    is_addressable() 
     29    is_commentable() 
    2230 
    2331class Order(Entity): 
     
    2735    using_options(shortnames=True) 
    2836    is_addressable('address', uselist=False) 
     37 
     38class Foo(Entity): 
     39    pass 
     40 
     41class Bar(Entity): 
     42    pass 
     43 
     44is_fooable = associable(Foo) 
     45is_barable = associable(Bar) 
     46 
     47class Quux(Entity): 
     48    is_fooable() 
     49    is_barable() 
    2950 
    3051class TestOrders(object): 
     
    3758        cleanup_all() 
    3859     
    39     def test_bidirectional(self): 
     60    def test_basic(self): 
    4061        home = Address(street='123 Elm St.', city='Spooksville') 
    4162        work = Address(street='243 Hooper st.', city='Cupertino')