def __init__(self, store, display_name=None, preferences=None): super(User, self).__init__() self._created_on = date_factory.now() user_id = uid_factory.new_uid() assert store.find(User, _user_id=user_id).count() == 0, ( 'Duplicate user id {0}'.format(user_id)) self._user_id = user_id self.display_name = ('' if display_name is None else display_name) self.preferences = preferences store.add(self)
def __init__(self, store, display_name=None, preferences=None): super().__init__() self._created_on = date_factory.now() user_id = uid_factory.new() assert store.query(User).filter_by(_user_id=user_id).count() == 0, ( 'Duplicate user id {}'.format(user_id)) self._user_id = user_id self.display_name = ('' if display_name is None else display_name) if preferences is not None: store.add(preferences) self.preferences = preferences store.add(self)