Changeset 4:14b2a12d495e in mailjam


Ignore:
Timestamp:
May 15, 2012, 4:41:48 PM (13 years ago)
Author:
Francisco de Borja Lopez Rio <borja@…>
Branch:
default
Phase:
public
Message:

Fixed some bugs in the code that was doing the de-serialization of data from
json-encoded files.

One of the bugs raised an exception complaining about the Member, MailingList
and JsonStorage classes not being found when de-serializing objects that
contain instances of such classes in their attributes. I fixed it adding some
imports to the init.py file within the postman/ module

The other bug was causing an infinite loop that was triggering a RuntimeError
(maximum recursion depth exceeded) when de-serializing MailingList instances
(a call to the .load() method in the init method of the MailingList class
was causing it)

Location:
postman
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • postman/__init__.py

    r1 r4  
     1# -*- coding: utf-8 -*-
     2
     3from models import Member, MailingList
     4from storage import JsonStorage
  • postman/models.py

    r2 r4  
    4242                                            self.address))
    4343        self.archive = Storage(os.path.join(self.config['archive'],
    44                                             self.address))
    45         # try to load data from the storage
    46         loaded = self.load()
    47         # FIXME: if loaded is False, the storage does not exist, perhaps
    48         # this would be a good place to create it for the first time
    49 
     44                                            self.address))       
     45       
    5046    def __repr__(self):
    5147        return "<MailingList '%s'>" % self.address
     
    7672            raise ValueError(address, ' is not a valid email address')
    7773        return address in self.members_addresses()
    78 
     74       
    7975    def members_addresses(self):
    8076        return self.members.keys()
  • postman/storage.py

    r1 r4  
    2121        Convert objects to a dictionary of their representation
    2222        Based on the exmplaes from Doyg Hellmann:
    23         http://www.doughellmann.com/PyMOTW/json/#working-with-your-own-types       
     23        http://www.doughellmann.com/PyMOTW/json/#working-with-your-own-types
    2424        """
    2525        jobj = { '__class__':obj.__class__.__name__,
Note: See TracChangeset for help on using the changeset viewer.