Changeset 8591


Ignore:
Timestamp:
02/10/12 09:02:12 (7 years ago)
Author:
mnagni
Message:

Corrects the GeographicExtent? (previosulsly the python's Decimal type was wrongly managed)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mauRepo/MolesManager/trunk/cedaMoles/MolesManager/views/moles2gui/__init__.py

    r8545 r8591  
    1010import inspect 
    1111from cedaMoles.libs.epb import isPrimitive 
     12from decimal import Decimal 
    1213 
    1314''' 
     
    183184    log = logging.getLogger('DJEncoder') 
    184185     
     186    __PATTERN = re.compile('\D\D__*') 
     187    __PATTERN2 = re.compile('\A\w+__id\Z') 
     188     
    185189    def __init__(self): 
    186190        self.__markers = {} 
    187         super(_Moles2guiEncoder, self).__init__() 
    188         self.__pattern = re.compile('\D\D__*') 
    189         self.__pattern2 = re.compile('\A\w+__id\Z') 
    190          
     191        super(_Moles2guiEncoder, self).__init__()         
    191192 
    192193    def default(self, obj):         
     
    194195        d = {} 
    195196     
     197        if isinstance(obj, Decimal): 
     198            return str(obj) 
     199     
    196200        if not hasattr(obj, "__dict__"): 
    197201            return d 
    198202     
    199203        for key in obj.__dict__.keys(): 
    200             if key in CedaMolesGuiAdapter.internal or not (key.startswith("_") or self.__pattern.match(key) or self.__pattern2.match(key)): 
     204            if key in CedaMolesGuiAdapter.internal \ 
     205                    or not (key.startswith("_") \ 
     206                    or _Moles2guiEncoder.__PATTERN.match(key) \ 
     207                    or _Moles2guiEncoder.__PATTERN2.match(key)): 
    201208                d.update({key: getattr(obj, key)}) 
    202209         
Note: See TracChangeset for help on using the changeset viewer.