Commits

Gregory Petukhov  committed 5795b1f

Remove export_data and import_data methods. Add `extra` property

  • Participants
  • Parent commits e8fd0bb

Comments (0)

Files changed (2)

 Extra data
 ==========
 
-It is possible to store in AuthKey instance extra data. All arguments of wrap_url function except uid and expired will be saved in the key record and will be accessible later via export_data method.
+It is possible to store in AuthKey instance extra data. All arguments of wrap_url function except uid and expired will be saved in the key record and will be accessible later via `extra` property.
 
 Usage example:
 
 'http://google.com?authkey=b68b4e38c0356c3eeb7a7ec6849a2dfc86902a10'
 >>> hash = url.split('=')[1]
 >>> key = load_key(hash)
->>> key.export_data()
+>>> key.extra
 {u'foo': u'bar', u'baz': 100}
 
 

File urlauth/models.py

 
         source = '%s%d%d' % (settings.SECRET_KEY, time.time(), id({}))
         key.id = sha1(source).hexdigest()
-        key.import_data(**kwargs)
+        key.data = simplejson.dumps(kwargs)
         key.save()
         return key.id
 
     def __unicode__(self):
         return 'AuthKey #%s' % self.id
 
-    def export_data(self):
+    @property
+    def extra(self):
         return simplejson.loads(self.data)
-
-    def import_data(self, **kwargs):
-        pairs = kwargs
-        self.data = simplejson.dumps(dict(pairs))