Coverage for gws-app/gws/base/model/value.py: 0%

20 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""Base model value.""" 

2 

3import gws 

4 

5 

6class Config(gws.Config): 

7 """Configuration for the model value.""" 

8 

9 isDefault: bool = False 

10 """The value is used only when no other value is provided.""" 

11 forRead: bool = True 

12 """The value is applied when reading an object.""" 

13 forCreate: bool = True 

14 """The value is applied when creating a new object.""" 

15 forUpdate: bool = True 

16 """The value is applied when updating an existing object.""" 

17 

18 

19class Object(gws.ModelValue): 

20 """Base model value. 

21 

22 Provides the ``isDefault`` flag and the set of operations the value applies to. 

23 Subclasses implement ``compute``. 

24 """ 

25 

26 def configure(self): 

27 self.isDefault = self.cfg('isDefault', default=False) 

28 

29 self.ops = set() 

30 

31 if self.cfg('forRead'): 

32 self.ops.add(gws.ModelOperation.read) 

33 if self.cfg('forCreate'): 

34 self.ops.add(gws.ModelOperation.create) 

35 if self.cfg('forUpdate'): 

36 self.ops.add(gws.ModelOperation.update)