bika.health.fields   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 27
dl 0
loc 87
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A field_setter.__call__() 0 2 1
A field_getter.__init__() 0 3 1
A field_getter.__call__() 0 2 1
A field_setter.__init__() 0 3 1
1
# -*- coding: utf-8 -*-
2
#
3
# This file is part of SENAITE.HEALTH.
4
#
5
# SENAITE.HEALTH is free software: you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by the Free
7
# Software Foundation, version 2.
8
#
9
# This program is distributed in the hope that it will be useful, but WITHOUT
10
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12
# details.
13
#
14
# You should have received a copy of the GNU General Public License along with
15
# this program; if not, write to the Free Software Foundation, Inc., 51
16
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
#
18
# Copyright 2018-2019 by it's authors.
19
# Some rights reserved, see README and LICENSE.
20
21
"""Generic field extensions"""
22
23
from Products.Archetypes.public import *
24
from archetypes.schemaextender.field import ExtensionField
25
from Products.ATExtensions.ateapi import RecordField, RecordsField
26
from Products.ATExtensions.ateapi import DateTimeField
27
28
29
class field_getter:
30
    "Used to mimic the Archetypes automatically generated accessor"
31
32
    def __init__(self, context, fieldname):
33
        self.context = context
34
        self.fieldname = fieldname
35
36
    def __call__(self):
37
        return self.context.Schema()[self.fieldname].getAccessor(self.context)()
38
39
40
class field_setter:
41
    "Used to mimic the Archetypes automatically generated mutator"
42
43
    def __init__(self, context, fieldname):
44
        self.context = context
45
        self.fieldname = fieldname
46
47
    def __call__(self, value):
48
        return self.context.Schema()[self.fieldname].getMutator(self.context)(value)
49
50
51
class ExtBooleanField(ExtensionField, BooleanField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable BooleanField does not seem to be defined.
Loading history...
52
    "Field extender"
53
54
55
class ExtComputedField(ExtensionField, ComputedField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable ComputedField does not seem to be defined.
Loading history...
56
    "Field extender"
57
58
59
class ExtDateTimeField(ExtensionField, DateTimeField):
60
    "Field extender"
61
62
63
class ExtIntegerField(ExtensionField, IntegerField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable IntegerField does not seem to be defined.
Loading history...
64
    "Field extender"
65
66
class ExtLinesField(ExtensionField, LinesField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable LinesField does not seem to be defined.
Loading history...
67
    "Field extender"
68
69
class ExtRecordField(ExtensionField, RecordField):
70
    "Field extender"
71
72
73
class ExtRecordsField(ExtensionField, RecordsField):
74
    "Field extender"
75
76
77
class ExtReferenceField(ExtensionField, ReferenceField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable ReferenceField does not seem to be defined.
Loading history...
78
    "Field extender"
79
80
81
class ExtStringField(ExtensionField, StringField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable StringField does not seem to be defined.
Loading history...
82
    "Field extender"
83
84
85
class ExtTextField(ExtensionField, TextField):
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable TextField does not seem to be defined.
Loading history...
86
    "Field extender"
87