diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-01-21 23:38:04 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-01-21 23:39:34 (GMT) |
commit | fb19a86a3d3d8e53fc13c22dfb2af7bf7d8d48ed (patch) | |
tree | 8c25739f4d3ee1076d619b8ebfddd90a52e97038 | |
parent | c8d833a4b02497223d9b35b89a501b74f7f480dd (diff) |
More reliable way to set GUID
-rw-r--r-- | restful_document/document.py | 2 | ||||
-rw-r--r-- | restful_document/user.py | 15 |
2 files changed, 7 insertions, 10 deletions
diff --git a/restful_document/document.py b/restful_document/document.py index 288b6d8..d3cae55 100644 --- a/restful_document/document.py +++ b/restful_document/document.py @@ -67,7 +67,7 @@ class Document(ad.Document): if prop is None: reply = [] for name, prop in self.metadata.items(): - if not isinstance(prop, ad.BlobProperty): + if prop.is_trait: reply.append(name) return self.all_properties(reply) elif isinstance(self.metadata[prop], ad.BlobProperty): diff --git a/restful_document/user.py b/restful_document/user.py index 4d713dc..2fcbd27 100644 --- a/restful_document/user.py +++ b/restful_document/user.py @@ -59,15 +59,16 @@ class User(Document): props = env.request.content enforce('pubkey' in props, _('Property "pubkey" is required for user registeration')) - props['manual_guid'], props['pubkey'] = \ - _load_pubkey(props['pubkey'].strip()) - doc = cls.create(props) - return {'guid': doc.guid} + guid, props['pubkey'] = _load_pubkey(props['pubkey'].strip()) + doc = cls(raw=['guid'], **props) + doc['guid'] = guid + doc.post() + return {'guid': guid} @classmethod def verify(cls, guid, signature): try: - pubkey = cls(guid, raw=True)['pubkey'] + pubkey = cls(guid, raw=['pubkey'])['pubkey'] except ad.NotFound: raise env.Unauthorized(_('Principal user does not exist')) if env.trust_users.value: @@ -84,10 +85,6 @@ class User(Document): # for all possible user documents Document.init(User) - def on_create(self, properties): - properties['guid'] = properties.pop('manual_guid') - Document.on_create(self, properties) - def _load_pubkey(pubkey): try: |