Completed
Push — master ( 68bc61...042191 )
by
unknown
02:38
created

TracimRequest.current_user()   A

Complexity

Conditions 2

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 2
nop 2
1
from contextlib import contextmanager
0 ignored issues
show
Coding Style introduced by
This module should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
Unused Code introduced by
Unused contextmanager imported from contextlib
Loading history...
2
3
from pyramid.decorator import reify
0 ignored issues
show
Unused Code introduced by
Unused reify imported from pyramid.decorator
Loading history...
4
from pyramid.request import Request
5
6
from tracim.models import User
7
from tracim.models.data import Workspace
8
from tracim.lib.utils.auth import get_safe_user
9
from tracim.lib.utils.auth import get_workspace
10
11
12
class TracimRequest(Request):
0 ignored issues
show
Coding Style introduced by
This class should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
best-practice introduced by
Too many ancestors (10/7)
Loading history...
Unused Code introduced by
The variable __class__ seems to be unused.
Loading history...
13
    def __init__(
14
            self,
15
            environ,
16
            charset=None,
17
            unicode_errors=None,
18
            decode_param_names=None,
19
            **kw
20
    ):
21
        super().__init__(
22
            environ,
23
            charset,
24
            unicode_errors,
25
            decode_param_names,
26
            **kw
27
        )
28
        self._current_workspace = None  # type: Workspace
29
        self._current_user = None  # type: User
30
31
    @property
32
    def current_workspace(self) -> Workspace:
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
33
        if self._current_workspace is None:
34
            self.current_workspace = get_workspace(self.current_user, self)
35
        return self._current_workspace
36
37
    @current_workspace.setter
38
    def current_workspace(self, workspace: Workspace) -> None:
39
        assert self._current_workspace is None
40
        self._current_workspace = workspace
41
42
    @property
43
    def current_user(self) -> User:
0 ignored issues
show
Coding Style introduced by
This method should have a docstring.

The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:

class SomeClass:
    def some_method(self):
        """Do x and return foo."""

If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.

Loading history...
44
        if self._current_user is None:
45
            self.current_user = get_safe_user(self)
46
        return self._current_user
47
48
    @current_user.setter
49
    def current_user(self, user: User) -> None:
50
        assert self._current_user is None
51
        self._current_user = user
52