Skip to content

Commit

Permalink
Remove saving back modified user objects (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-w authored Jan 31, 2020
1 parent fa9695b commit 1916fdd
Showing 1 changed file with 1 addition and 16 deletions.
17 changes: 1 addition & 16 deletions opwen_email_server/integration/webapp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from datetime import datetime
from typing import Callable
from typing import Dict
from typing import Iterable
from typing import List
from typing import Optional
Expand Down Expand Up @@ -48,10 +47,6 @@ def __setattr__(self, key, value):
data = super().__getattribute__('_data')
data[key] = value

def to_dict(self):
data = super().__getattribute__('_data')
return data

@property
def id(self) -> Union[str, int]:
return self.email
Expand Down Expand Up @@ -82,7 +77,6 @@ def __init__(self, user_storage: AzureObjectStorage):
UserReadStore.__init__(self, user_model=AzureUser, role_model=AzureRole)
UserWriteStore.__init__(self, db=None)
UserStore.__init__(self, read=self, write=self)
self._pending_users: Dict[str, AzureUser] = {}
self._user_storage = user_storage

def init_app(self, app):
Expand Down Expand Up @@ -118,21 +112,12 @@ def find_role(self, *args, **kwargs):
raise NotImplementedError

def put(self, user: AzureUser) -> AzureUser:
self._pending_users[user.email] = user
return user

def commit(self) -> None:
for user in self._pending_users.values():
data = user.to_dict()

# FIXME: deal with datetime serialization
data.pop('last_login_at', None)
data.pop('current_login_at', None)

self._user_storage.store_object(self._path_for(user.email), data)
pass

def delete(self, user: AzureUser) -> None:
self._pending_users.pop(user.email, None)
self._user_storage.delete(self._path_for(user.email))

@classmethod
Expand Down

0 comments on commit 1916fdd

Please sign in to comment.