Changeset 3606

Show
Ignore:
Timestamp:
10/23/07 16:45:00 (1 year ago)
Author:
pobrien
Message:

Better string and unicode representations. Needs unit tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Schevo/schevo/field.py

    r3561 r3606  
    12681268    allow_unassigned = False 
    12691269 
     1270    def __str__(self): 
     1271        v = self.get() 
     1272        if v is UNASSIGNED: 
     1273            return '<UNASSIGNED>' 
     1274        else: 
     1275            return ', '.join(str(item) for item in v) 
     1276 
     1277    def __unicode__(self): 
     1278        v = self.get() 
     1279        if v is UNASSIGNED: 
     1280            return u'<UNASSIGNED>' 
     1281        else: 
     1282            return u', '.join(unicode(item) for item in v) 
     1283 
    12701284    def convert(self, value, db=None): 
    12711285        if isinstance(value, (list, tuple)): 
     
    14241438    """Set of Entity instances field class.""" 
    14251439 
     1440    def __str__(self): 
     1441        v = self.get() 
     1442        if v is UNASSIGNED: 
     1443            return '<UNASSIGNED>' 
     1444        else: 
     1445            return ', '.join(str(item) for item in v) 
     1446 
     1447    def __unicode__(self): 
     1448        v = self.get() 
     1449        if v is UNASSIGNED: 
     1450            return u'<UNASSIGNED>' 
     1451        else: 
     1452            return u', '.join(unicode(item) for item in v) 
     1453 
    14261454    def convert(self, value, db=None): 
    14271455        if isinstance(value, (set, frozenset)): 
     
    15131541class EntitySetSet(_EntityBase): 
    15141542    """Set of EntitySet instances field class.""" 
     1543 
     1544    def __str__(self): 
     1545        v = self.get() 
     1546        if v is UNASSIGNED: 
     1547            return '<UNASSIGNED>' 
     1548        else: 
     1549            return '; '.join(', '.join(str(item) for item in items) 
     1550                             for items in v) 
     1551 
     1552    def __unicode__(self): 
     1553        v = self.get() 
     1554        if v is UNASSIGNED: 
     1555            return u'<UNASSIGNED>' 
     1556        else: 
     1557            return '; '.join(u', '.join(unicode(item) for item in items) 
     1558                             for items in v) 
    15151559 
    15161560    def convert(self, value, db=None):