Browse Source

fixing documentation

still don't like ReST
master
Holger Frey 7 years ago
parent
commit
85a99b1d6a
  1. 22
      ordr2/models/account.py
  2. 4
      ordr2/resources/base.py
  3. 2
      ordr2/security.py
  4. 1
      ordr2/session.py

22
ordr2/models/account.py

@ -85,7 +85,7 @@ class User(Base):
username = Column(Text, nullable=False, unique=True) username = Column(Text, nullable=False, unique=True)
#: hashed password, see :mod:`ordr2.security` #: hashed password, see :mod:`ordr2.security`
password_hash = Column(Text, nullable=False) password_hash = Column(Text, nullable=False)
#: role of the user, see :class:`ordr2.models.users.Role` #: role of the user, see :class:`ordr2.models.account.Role`
role = Column(Enum(Role), nullable=False) role = Column(Enum(Role), nullable=False)
first_name = Column(Text, nullable=False) first_name = Column(Text, nullable=False)
@ -159,8 +159,8 @@ class User(Base):
what the token is used for what the token is used for
:type subject: :type subject:
ordr2.models.account.TokenSubject ordr2.models.account.TokenSubject
:param **payload: :param payload:
etra data to store with the token, must be JSON serializable extra data to store with the token, must be JSON serializable
:rtype: :rtype:
(str) unique hash to access the token (str) unique hash to access the token
''' '''
@ -176,11 +176,23 @@ class Token(Base):
''' Tokens for mail change, account verification and password reset ''' ''' Tokens for mail change, account verification and password reset '''
__tablename__ = 'tokens' __tablename__ = 'tokens'
#: hash identifyer of the token
hash = Column(Unicode, primary_key=True) hash = Column(Unicode, primary_key=True)
#: :class:`ordr2.models.account.TokenSubject`
subject = Column(Enum(TokenSubject), nullable=False) subject = Column(Enum(TokenSubject), nullable=False)
#: token expires at this date and time
expires = Column(DateTime, nullable=False) expires = Column(DateTime, nullable=False)
#: additional data to attach to a token
payload = Column(JsonEncoder, nullable=False) payload = Column(JsonEncoder, nullable=False)
#: the user_id the token belongs to
owner_id = Column(Integer, ForeignKey('users.id')) owner_id = Column(Integer, ForeignKey('users.id'))
#: the user the token belongs to
owner = relationship('User', back_populates='tokens') owner = relationship('User', back_populates='tokens')
@classmethod @classmethod
@ -207,8 +219,8 @@ class Token(Base):
account the token is issued for account the token is issued for
:type subject: :type subject:
ordr2.models.account.User ordr2.models.account.User
:param **payload: :param payload:
etra data to store with the token, must be JSON serializable extra data to store with the token, must be JSON serializable
:rtype: :rtype:
ordr2.models.account.Token ordr2.models.account.Token
''' '''

4
ordr2/resources/base.py

@ -52,7 +52,9 @@ class BaseResource(object):
:param str key: :param str key:
path segment for a child resource path segment for a child resource
:rtype: :rtype:
ordr2.resources.BaseResource or KeyError subclass of ordr2.resources.base.BaseResource
:raises:
KeyError if path segment is not found
''' '''
node_class = self.nodes[key] node_class = self.nodes[key]
return node_class(key, self) return node_class(key, self)

2
ordr2/security.py

@ -38,7 +38,7 @@ def get_user(request):
:type request: :type request:
pyramid.request.Request pyramid.request.Request
:rtype: :rtype:
ordr2.models.users.User or None :class:`ordr2.models.account.User` or None
''' '''
user_id = request.unauthenticated_userid user_id = request.unauthenticated_userid
if user_id is not None: if user_id is not None:

1
ordr2/session.py

@ -1,7 +1,6 @@
''' Session configuration ''' ''' Session configuration '''
import binascii import binascii
from pyramid.session import BaseCookieSessionFactory
from pyramid_nacl_session import EncryptedCookieSessionFactory from pyramid_nacl_session import EncryptedCookieSessionFactory