• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SwissDataScienceCenter / renku-python / 9058668052

13 May 2024 07:05AM UTC coverage: 77.713% (-8.4%) from 86.115%
9058668052

Pull #3727

github

web-flow
Merge 128d38387 into 050ed61bf
Pull Request #3727: fix: don't fail session launch when gitlab couldn't be reached

15 of 29 new or added lines in 3 files covered. (51.72%)

2594 existing lines in 125 files now uncovered.

23893 of 30745 relevant lines covered (77.71%)

3.2 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/renku/infrastructure/persistent.py
1
# Copyright Swiss Data Science Center (SDSC). A partnership between
2
# École Polytechnique Fédérale de Lausanne (EPFL) and
3
# Eidgenössische Technische Hochschule Zürich (ETHZ).
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16
"""Base Renku persistent class."""
7✔
17

18
import persistent
7✔
19

20

21
class Persistent(persistent.Persistent):
7✔
22
    """Base Persistent class for renku classes.
23

24
    Subclasses are assumed to be immutable once persisted to the database. If a class shouldn't be immutable then
25
    subclass it directly from persistent.Persistent.
26
    """
27

28
    _v_immutable = False
7✔
29

30
    def reassign_oid(self):
7✔
31
        """Reassign ``oid`` (after assigning a new identifier for example)."""
32
        from renku.infrastructure.database import Database
6✔
33

34
        if self._p_jar is not None:
6✔
UNCOV
35
            self._p_jar.remove_from_cache(self)
×
36

37
        self._p_oid = None
6✔
38
        self._p_oid = Database.generate_oid(self)
6✔
39

40
    @property
7✔
41
    def immutable(self):
7✔
42
        """Return if object is immutable."""
43
        return self._v_immutable
6✔
44

45
    def freeze(self):
7✔
46
        """Set immutable property."""
47
        self._v_immutable = True
6✔
48

49
    def unfreeze(self):
7✔
50
        """Allows modifying an immutable object.
51

52
        Don't make an object mutable unless the intention is to drop the changes or modify the object in-place. Modified
53
        objects will be updated in-place which results in a binary diff when persisted. Normally, we want to create a
54
        mutable copy and persist it as a new object.
55
        """
56
        self._v_immutable = False
6✔
57

58
    def __setattr__(self, key, value):
7✔
59
        if self._v_immutable and key != "__weakref__" and not key.startswith("_p_") and not key.startswith("_v_"):
6✔
60
            raise RuntimeError(f"Cannot modify immutable object {self}.{key}")
×
61

62
        super().__setattr__(key, value)
6✔
63

64
    @property
7✔
65
    def __name__(self):
7✔
66
        return self.__class__.__name__
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc