-
Notifications
You must be signed in to change notification settings - Fork 169
/
__init__.py
209 lines (191 loc) · 9.06 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
import warnings
import pkg_resources
__version__ = pkg_resources.get_distribution("bika.lims").version
# import this to create messages in the bika domain.
from zope.i18nmessageid import MessageFactory
bikaMessageFactory = MessageFactory('bika')
_ = MessageFactory('bika.lims')
from Products.Archetypes import PloneMessageFactory as PMF
# import this to log messages
import logging
logger = logging.getLogger('Bika')
from bika.lims.validators import *
from bika.lims.config import *
from bika.lims.permissions import *
from AccessControl import ModuleSecurityInfo, allow_module
from Products.Archetypes.atapi import process_types, listTypes
from Products.CMFCore import utils
from Products.CMFCore.DirectoryView import registerDirectory
from Products.CMFCore.utils import ContentInit, ToolInit, getToolByName
from Products.CMFPlone import PloneMessageFactory
from Products.CMFPlone.interfaces import IPloneSiteRoot
from Products.GenericSetup import EXTENSION, profile_registry
allow_module('AccessControl')
allow_module('bika.lims')
allow_module('bika.lims.config')
allow_module('bika.lims.permissions')
allow_module('bika.lims.utils')
allow_module('json')
allow_module('zope.i18n.locales')
allow_module('zope.component')
allow_module('plone.registry.interfaces')
import App
debug_mode = App.config.getConfiguration().debug_mode
if debug_mode:
allow_module('pdb')
allow_module('pudb')
def initialize(context):
from content.analysis import Analysis
from content.analysiscategory import AnalysisCategory
from content.analysisrequest import AnalysisRequest
from content.analysisrequestsfolder import AnalysisRequestsFolder
from content.analysisservice import AnalysisService
from content.analysisspec import AnalysisSpec
from content.arimport import ARImport
from content.arpriority import ARPriority
from content.analysisprofile import AnalysisProfile
from content.arreport import ARReport
from content.artemplate import ARTemplate
from content.attachment import Attachment
from content.attachmenttype import AttachmentType
from content.batch import Batch
from content.batchfolder import BatchFolder
from content.batchlabel import BatchLabel
from content.bikaschema import BikaSchema
from content.bikasetup import BikaSetup
from content.calculation import Calculation
from content.client import Client
from content.clientfolder import ClientFolder
from content.contact import Contact
from content.container import Container
from content.containertype import ContainerType
from content.department import Department
from content.duplicateanalysis import DuplicateAnalysis
from content.instrument import Instrument
from content.instrumentcalibration import InstrumentCalibration
from content.instrumentcertification import InstrumentCertification
from content.instrumentmaintenancetask import InstrumentMaintenanceTask
from content.instrumentscheduledtask import InstrumentScheduledTask
from content.instrumentvalidation import InstrumentValidation
from content.instrumenttype import InstrumentType
from content.invoice import Invoice
from content.invoicebatch import InvoiceBatch
from content.invoicefolder import InvoiceFolder
from content.labcontact import LabContact
from content.laboratory import Laboratory
from content.labproduct import LabProduct
from content.manufacturer import Manufacturer
from content.method import Method
from content.methods import Methods
from content.multifile import Multifile
from content.organisation import Organisation
from content.person import Person
from content.preservation import Preservation
from content.pricelist import Pricelist
from content.pricelistfolder import PricelistFolder
from content.referenceanalysis import ReferenceAnalysis
from content.referencedefinition import ReferenceDefinition
from content.referencesample import ReferenceSample
from content.referencesamplesfolder import ReferenceSamplesFolder
from content.rejectanalysis import RejectAnalysis
from content.report import Report
from content.reportfolder import ReportFolder
from content.sample import Sample
from content.samplecondition import SampleCondition
from content.samplematrix import SampleMatrix
from content.samplepartition import SamplePartition
from content.samplepoint import SamplePoint
from content.storagelocation import StorageLocation
from content.samplesfolder import SamplesFolder
from content.sampletype import SampleType
from content.samplingdeviation import SamplingDeviation
from content.srtemplate import SRTemplate
from content.subgroup import SubGroup
from content.supplier import Supplier
from content.suppliercontact import SupplierContact
from content.supplyorderfolder import SupplyOrderFolder
from content.supplyorder import SupplyOrder
from content.worksheet import Worksheet
from content.worksheetfolder import WorksheetFolder
from content.worksheettemplate import WorksheetTemplate
from controlpanel.bika_analysiscategories import AnalysisCategories
from controlpanel.bika_analysisservices import AnalysisServices
from controlpanel.bika_analysisspecs import AnalysisSpecs
from controlpanel.bika_analysisprofiles import AnalysisProfiles
from controlpanel.bika_artemplates import ARTemplates
from controlpanel.bika_arpriorities import ARPriorities
from controlpanel.bika_attachmenttypes import AttachmentTypes
from controlpanel.bika_batchlabels import BatchLabels
from controlpanel.bika_calculations import Calculations
from controlpanel.bika_containers import Containers
from controlpanel.bika_containertypes import ContainerTypes
from controlpanel.bika_departments import Departments
from controlpanel.bika_instruments import Instruments
from controlpanel.bika_instrumenttypes import InstrumentTypes
from controlpanel.bika_labcontacts import LabContacts
from controlpanel.bika_labproducts import LabProducts
from controlpanel.bika_manufacturers import Manufacturers
from controlpanel.bika_preservations import Preservations
from controlpanel.bika_referencedefinitions import ReferenceDefinitions
from controlpanel.bika_sampleconditions import SampleConditions
from controlpanel.bika_samplematrices import SampleMatrices
from controlpanel.bika_samplepoints import SamplePoints
from controlpanel.bika_storagelocations import StorageLocations
from controlpanel.bika_sampletypes import SampleTypes
from controlpanel.bika_samplingdeviations import SamplingDeviations
from controlpanel.bika_srtemplates import SRTemplates
from controlpanel.bika_subgroups import SubGroups
from controlpanel.bika_suppliers import Suppliers
from controlpanel.bika_worksheettemplates import WorksheetTemplates
content_types, constructors, ftis = process_types(
listTypes(PROJECTNAME),
PROJECTNAME)
# Register each type with it's own Add permission
# use ADD_CONTENT_PERMISSION as default
allTypes = zip(content_types, constructors)
for atype, constructor in allTypes:
kind = "%s: Add %s" % (config.PROJECTNAME, atype.portal_type)
perm = ADD_CONTENT_PERMISSIONS.get(atype.portal_type,
ADD_CONTENT_PERMISSION)
ContentInit(kind,
content_types = (atype,),
permission = perm,
extra_constructors = (constructor,),
fti = ftis,
).initialize(context)
def deprecated(comment=None, replacement=None):
""" A decorator which can be used to mark functions as deprecated.
Emits a DeprecationWarning showing the module and method being flagged
as deprecated. If replacement is set, the warn will also show which is
the function or class to be used instead.
"""
def old(oldcall):
def new(*args, **kwargs):
message = "Deprecated: '%s.%s'" % \
(oldcall.__module__,
oldcall.__name__)
if replacement is not None:
message += ". Use '%s.%s' instead" % \
(replacement.__module__,
replacement.__name__)
if comment is not None:
message += ". %s" % comment
warnings.warn(message, category=DeprecationWarning, stacklevel=2)
return oldcall(*args, **kwargs)
return new
return old
class _DeprecatedClassDecorator(object):
""" A decorator which can be used to mark symbols as deprecated.
Emits a DeprecationWarning showing the symbol being flagged as
deprecated. For add comments, use deprecated() instead of it
"""
def __call__(self, symbol):
message = "Deprecated: '%s.%s'" % \
(symbol.__module__,
symbol.__name__)
warnings.warn(message, category=DeprecationWarning, stacklevel=2)
return symbol
deprecatedsymbol = _DeprecatedClassDecorator()
del _DeprecatedClassDecorator
def enum(**enums):
return type('Enum', (), enums)