def resize(self, size, instance=None):
        oldsize = self.getPhysicalSize()

        #only do a physical resize when growing
        if size > oldsize or size==0 and oldsize==0:
            self.already_bootstrapped = False
            schema = Schema(())
            schema.addField(IntegerField('size'))
            fn = self.field.getName()

            for idx in range(max(size, 1)):
                f1 = self.field.copy()
                f1.__name__ = '%s%s%03d' % (fn, 
                                            config.ARRAY_FIELDNAME_SEPARATOR, 
                                            idx)
                schema.addField(f1)

            self.setSchema(schema=schema)
            self.physicalSize = size

        if instance:
            # field 0 is always size. has to be adressed by index because fields 
            # get renamed during nesting
            lf = self.Schema().fields()[0] 
            lf.set(instance, size)
            # We need to force a bootstrapping of the accessors by calling
            # getAccessor. There was a strange bug:
            # After a restart the content of an array field with a size
            # greater than default was not shown until after
            # a reload. Apparently the accessors was accessed
            # before the resize triggered by getSize().
            self.getAccessor(instance)
        else:
            self.size = size
예제 #2
0
class SkinMethod(BaseContentMixin):

    meta_type = portal_type = archetype_name = 'CompositePack Skin Method'
    global_allow = 0

    schema = base_schema + Schema((StringField(
        'skin_method',
        accessor='getSkinMethod',
        mutator='setSkinMethod',
        widget=StringWidget(label='Skin Method',
                            description=('Method called for rendering '
                                         'the viewlet/layout.'))), ))

    def getId(self):
        if getattr(self, '_at_is_fake_instance', False):
            return ''
        return super(SkinMethod, self).getId()

    def getTemplate(self):
        """ Return the template """
        purl = getToolByName(self, 'portal_url')
        portal = purl.getPortalObject()
        return portal.restrictedTraverse(self.getSkinMethod())

    def indexObject(self):
        '''skin method is never catalogued'''
        pass

    def reindexObject(self, idxs=[]):
        '''skin method is never catalogued'''
        pass

    def unindexObject(self):
        '''skin method is never catalogued'''
        pass
예제 #3
0
from Products.CompositePack.exceptions import CompositePackError

base_schema = Schema(
    (
        StringField(
            name='id',
            required=1,
            mode='rw',
            permission=copy_or_move,
            accessor='getId',
            mutator='setId',
            default='',
            widget=RequiredIdWidget(
                ignore_visible_ids=True,  # Always show the widget
            ),
        ),
        StringField(
            name='title',
            required=1,
            searchable=1,
            default='',
            accessor='Title',
            widget=StringWidget(
                label_msgid='label_title',
                visible={'view': 'invisible'},
                i18n_domain='plone',
            ),
        ),
    ),
    marshall=RFC822Marshaller())

예제 #4
0
except ImportError:
    from Products.Archetypes.generator import i18n

from Products.CompoundField import config

##code-section module-header #fill in your manual code here
##/code-section module-header

from Products.CompoundField.ArrayField import ArrayField

from Products.CompoundField.CompoundField import CompoundField
######CompoundField
schema = Schema((ArrayField(
    StringField(name='simpleString',
                widget=StringWidget(
                    label='Simplestring',
                    label_msgid='CompoundField_label_simpleString',
                    i18n_domain='CompoundField',
                )), ), ), )


class SimpleCompoundTestField(CompoundField):
    """
    """
    ##code-section class-header #fill in your manual code here
    ##/code-section class-header

    __implements__ = (getattr(CompoundField, '__implements__', ()), )

    _properties = CompoundField._properties.copy()
    _properties.update({
예제 #5
0
schema = BikaSchema.copy() + Schema((
    ShortTitle,
    SortKey,
    CommercialID,
    ProtocolID,
    ScientificName,
    Unit,
    Precision,
    ExponentialFormatPrecision,
    LowerDetectionLimit,
    UpperDetectionLimit,
    DetectionLimitSelector,
    AllowManualDetectionLimit,
    AttachmentOption,
    Keyword,
    ManualEntryOfResults,
    InstrumentEntryOfResults,
    Instrument,
    Method,
    MaxTimeAllowed,
    DuplicateVariation,
    Accredited,
    PointOfCapture,
    Category,
    Price,
    BulkPrice,
    VAT,
    Department,
    Uncertainties,
    PrecisionFromUncertainty,
    AllowManualUncertainty,
    ResultOptions,
    Hidden,
    SelfVerification,
    NumberOfRequiredVerifications,
    Remarks,
    StringResult,
))
예제 #6
0
schema = Schema((


    IntegerField(
        name='startLine',
        widget=IntegerField._properties['widget'](
            label='StartLine',
            label_msgid='Newspaper_label_startLine',
            i18n_domain='Newspaper',
        ),
    ),
    IntegerField(
        name='endLine',
        widget=IntegerField._properties['widget'](
            label='EndLine',
            label_msgid='Newspaper_label_endLine',
            i18n_domain='Newspaper',
        ),
    ),
    IntegerField(
        name='fontSize',
	default=11,
        widget=IntegerField._properties['widget'](
            label='fontSize',
            label_msgid='Newspaper_label_fontSize',
            i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='useRemainder',
        widget=BooleanField._properties['widget'](
	    label='useRemainder',
	    label_msgid='Newspaper_label_useRemainder',
	    i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='useContinuedOn',
        widget=BooleanField._properties['widget'](
	    label='useContinuedOn',
	    label_msgid='Newspaper_label_useContinuedOn',
	    i18n_domain='Newspaper',
	),
    ),
    StringField(
        name='continuedOn',
	default='Continued on Page Four',
        widget=StringField._properties['widget'](
            label='Continued On',
            label_msgid='Newspaper_label_continuedon',
            i18n_domain='Newspaper',
        ),
    ),
    BooleanField(
	name='useContinuedFrom',
        widget=BooleanField._properties['widget'](
	    label='useContinuedFrom',
	    label_msgid='Newspaper_label_useContinuedFrom',
	    i18n_domain='Newspaper',
	),
    ),
    StringField(
        name='continuedFrom',
	default='Continued From Page One',
        widget=StringField._properties['widget'](
            label='Continued From',
            label_msgid='Newspaper_label_continuedfrom',
            i18n_domain='Newspaper',
        ),
    ),
    IntegerField(
	name='charsPerLine',
	widget=IntegerField._properties['widget'](
            label='Characters per Line',
	    label_msgid='Newspaper_label_charsPerLine',
	    i18n_domain='Newspaper',
	),
    ),
    StringField(
        name='textclass',
	default='textclass',
        widget=StringField._properties['widget'](
            label='Text class',
            label_msgid='Newspaper_label_textclass',
            i18n_domain='Newspaper',
        ),
    ),
    BooleanField(
	name='glueX',
        widget=BooleanField._properties['widget'](
	    label='glueX',
	    label_msgid='Newspaper_label_glueX',
	    i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='glueY',
        widget=BooleanField._properties['widget'](
	    label='glueY',
	    label_msgid='Newspaper_label_glueY',
	    i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='offsetX',
        widget=BooleanField._properties['widget'](
	    label='offsetX',
	    label_msgid='Newspaper_label_offsetX',
	    i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='resetY',
        widget=BooleanField._properties['widget'](
	    label='resetY',
	    label_msgid='Newspaper_label_resetY',
	    i18n_domain='Newspaper',
	),
    ),
    BooleanField(
	name='addLineHeight',
        widget=BooleanField._properties['widget'](
	    label='addLineHeight',
	    label_msgid='Newspaper_label_addLineHeight',
	    i18n_domain='Newspaper',
	),
    ),
    ReferenceField(
        name='wordage',
        widget=InAndOutWidget(
            label='Containers',
            label_msgid='Newspaper_label_containers',
            i18n_domain='Newspaper',
        ),
        allowed_types=('Article',),
        multiValued=1,
        relationship='containerLocation',
    ),
),
)
예제 #7
0
    name='Address',
    widget=AddressWidget(
        label=_("Address"),
        render_own_label=True,
        showCopyFrom=False,
    ),
    subfield_validators={
        'country': 'inline_field_validator',
        'state': 'inline_field_validator',
        'district': 'inline_field_validator',
    },
)

schema = BikaFolderSchema.copy() + Schema((
    Phone,
    EmailAddress,
    Address,
))


class StorageFacility(ATFolder):
    """Physical location or place where storage containers are located
    """
    implements(IStorageFacility)
    _at_rename_after_creation = True
    displayContentsTab = False
    schema = schema

    def _renameAfterCreation(self, check_auto_id=False):
        renameAfterCreation(self)
예제 #8
0
schema = Schema(
    (
        ReferenceField(
            name="article",
            widget=InAndOutWidget(label="Article", label_msgid="Newspaper_label_article", i18n_domain="Newspaper"),
            allowed_types=("Wordage",),
            multiValued=1,
            relationship="containerLocation",
        ),
        IntegerField(
            name="startLine",
            widget=IntegerField._properties["widget"](
                label="StartLine", label_msgid="Newspaper_label_startLine", i18n_domain="Newspaper"
            ),
        ),
        IntegerField(
            name="endLine",
            widget=IntegerField._properties["widget"](
                label="EndLine", label_msgid="Newspaper_label_endLine", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="useRemainder",
            widget=BooleanField._properties["widget"](
                label="useRemainder", label_msgid="Newspaper_label_useRemainder", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="useContinuedOn",
            widget=BooleanField._properties["widget"](
                label="useContinuedOn", label_msgid="Newspaper_label_useContinuedOn", i18n_domain="Newspaper"
            ),
        ),
        StringField(
            name="continuedOn",
            default="Continued on Page Four",
            widget=StringField._properties["widget"](
                label="Continued On", label_msgid="Newspaper_label_continuedon", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="useContinuedFrom",
            widget=BooleanField._properties["widget"](
                label="useContinuedFrom", label_msgid="Newspaper_label_useContinuedFrom", i18n_domain="Newspaper"
            ),
        ),
        StringField(
            name="continuedFrom",
            default="Continued From Page One",
            widget=StringField._properties["widget"](
                label="Continued From", label_msgid="Newspaper_label_continuedfrom", i18n_domain="Newspaper"
            ),
        ),
        IntegerField(
            name="charsPerLine",
            widget=IntegerField._properties["widget"](
                label="Characters per Line", label_msgid="Newspaper_label_charsPerLine", i18n_domain="Newspaper"
            ),
        ),
        IntegerField(
            name="offsetXWidth",
            default=0,
            widget=IntegerField._properties["widget"](
                label="X Column Offset", label_msgid="Newspaper_label_offsetXWidth", i18n_domain="Newspaper"
            ),
        ),
        IntegerField(
            name="offsetYHeight",
            default=0,
            widget=IntegerField._properties["widget"](
                label="Y Column Offset", label_msgid="Newspaper_label_offsetXWidth", i18n_domain="Newspaper"
            ),
        ),
        StringField(
            name="textclass",
            default="textclass",
            widget=StringField._properties["widget"](
                label="Text class", label_msgid="Newspaper_label_textclass", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="glueX",
            widget=BooleanField._properties["widget"](
                label="glueX", label_msgid="Newspaper_label_glueX", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="glueY",
            widget=BooleanField._properties["widget"](
                label="glueY", label_msgid="Newspaper_label_glueY", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="offsetX",
            widget=BooleanField._properties["widget"](
                label="offsetX", label_msgid="Newspaper_label_offsetX", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="resetY",
            widget=BooleanField._properties["widget"](
                label="resetY", label_msgid="Newspaper_label_resetY", i18n_domain="Newspaper"
            ),
        ),
        BooleanField(
            name="addLineHeight",
            widget=BooleanField._properties["widget"](
                label="addLineHeight", label_msgid="Newspaper_label_addLineHeight", i18n_domain="Newspaper"
            ),
        ),
    )
)
예제 #9
0
                               subfield_types={
                                   "row": "int",
                                   "column": "int",
                                   "samples_capacity": "int",
                                   "samples_utilization": "int"
                               },
                               widget=RecordsWidget(visible=False))

AvailablePositions = LinesField(name="AvailablePositions",
                                required=0,
                                subfields=("row", "column"),
                                widget=LinesWidget(visible=False))

schema = BikaFolderSchema.copy() + Schema((
    Rows,
    Columns,
    PositionsLayout,
    AvailablePositions,
))


class StorageLayoutContainer(ATFolder):
    """Base class for storage containers
    """
    implements(IStorageLayoutContainer)
    _at_rename_after_creation = True
    displayContentsTab = False
    schema = schema
    default_samples_capacity = 0

    def _renameAfterCreation(self, check_auto_id=False):
        renameAfterCreation(self)
예제 #10
0
)

SortKey = FloatField(
    "SortKey",
    validators=("SortKeyValidator",),
    widget=DecimalWidget(
        label=_("Sort Key"),
        description=_(
            "Float value from 0.0 - 1000.0 indicating the sort order. "
            "Duplicate values are ordered alphabetically."),
    ),
)

schema = BikaSchema.copy() + Schema((
    Comments,
    Department,
    SortKey,
))

schema['description'].widget.visible = True
schema['description'].schemata = 'default'


class AnalysisCategory(BaseContent):
    implements(IAnalysisCategory, IHaveDepartment, IDeactivable)
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema

    _at_rename_after_creation = True
예제 #11
0
from bika.lims.browser.widgets.decimal import DecimalWidget
from senaite.storage import PRODUCT_NAME
from senaite.storage import senaiteMessageFactory as _
from senaite.storage.content.storagelayoutcontainer import \
    StorageLayoutContainer
from senaite.storage.content.storagelayoutcontainer import schema
from senaite.storage.interfaces import IStorageContainer
from zope.interface import implements

Temperature = FloatField(
    name="Temperature",
    widget=DecimalWidget(
        label=_("Expected temperature"),
        description=_("Expected temperature of this container")))

schema = schema.copy() + Schema((Temperature, ))


class StorageContainer(StorageLayoutContainer):
    """Container for the storage of other storage containers
    """
    implements(IStorageContainer)
    schema = schema

    def is_object_allowed(self, object_brain_uid):
        """Returns whether the type of object can be stored or not in this
        container. This function returns true if the object is allowed, even
        if the container already contains the object
        """
        # Only children from this container are allowed
        obj = api.get_object(object_brain_uid)
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CompoundField.ArrayField import ArrayField
from Products.CompoundField.ArrayWidget import ArrayWidget
from Products.CompoundField.EnhancedArrayWidget import EnhancedArrayWidget

from Products.CompoundField.CompoundField import CompoundField
######CompoundField
schema = Schema((ArrayField(
    XPointField(
        name='polypoints',
        widget=XPointField._properties['widget'](
            label='Polypoints',
            label_msgid='CompoundField_label_polypoints',
            i18n_domain='CompoundField',
        ),
    ),
    widget=EnhancedArrayWidget(
        label='Array:polypoints',
        label_msgid='CompoundField_label_array:polypoints',
        i18n_domain='CompoundField',
    ),
), ), )


class XPolygonField(CompoundField):
    """
    """
    ##code-section class-header #fill in your manual code here
    ##/code-section class-header
예제 #13
0
 def __init__(self, schemas=None):
     self._schemas = [Schema()]
     if schemas is not None:
         self.addSchemas(schemas)
예제 #14
0
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CompoundField.ArrayField import ArrayField
from Products.CompoundField.ArrayWidget import ArrayWidget
from Products.CompoundField.EnhancedArrayWidget import EnhancedArrayWidget

from Products.CompoundField.CompoundField import CompoundField
######CompoundField
schema = Schema((ArrayField(
    StringField(
        name='arrayOfString',
        widget=StringField._properties['widget'](
            label='Arrayofstring',
            label_msgid='CompoundField_label_arrayOfString',
            i18n_domain='CompoundField',
        ),
    ),
    widget=EnhancedArrayWidget(
        label='Array:arrayofstring',
        label_msgid='CompoundField_label_array:arrayOfString',
        i18n_domain='CompoundField',
    ),
), ), )


class NestedArrayField(CompoundField):
    """
    """
    ##code-section class-header #fill in your manual code here
    ##/code-section class-header
예제 #15
0
from zope.interface import implements
from Products.CompoundField.testClasses.XPointField import XPointField
from Products.CompoundField.testClasses.XBox import XBox
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CompoundField.CompoundField import CompoundField
######CompoundField
schema = Schema((
    XPointField(
        name='p1',
        widget=XPointField._properties['widget'](
            label='P1',
            label_msgid='CompoundField_label_p1',
            i18n_domain='CompoundField',
        ),
    ),
    XPointField(
        name='p2',
        widget=XPointField._properties['widget'](
            label='P2',
            label_msgid='CompoundField_label_p2',
            i18n_domain='CompoundField',
        ),
    ),
), )


class XBoxField(CompoundField):
    """
    """
    ##code-section class-header #fill in your manual code here
    ##/code-section class-header
class CompoundField(ObjectField):
    """
    """
    ##code-section class-header #fill in your manual code here
    security = ClassSecurityInfo()
    security.declarePublic('getFields')
    schema = Schema(())
    ##/code-section class-header

    implements(ICompoundField)

    _properties = ObjectField._properties.copy()
    _properties.update({
        'type': 'compoundfield',
        'widget': CompoundWidget,
        'validators': CompoundValidator(),
        ##code-section field-properties #fill in your manual code here
        ##/code-section field-properties
    })

    security = ClassSecurityInfo()

    security.declarePrivate('set')
    security.declarePrivate('get')

    #from Interface ICompoundField:
    def Schema(self, ):
        """Returns the Schemata for the CompoundField
        """
        return self.schema

    def getRaw(self, instance, **kwargs):
        res = dict()
        for f in self.Schema().fields():
            if hasattr(f, 'getRaw'):
                res[f.old_name] = (f.getRaw(instance, schema=self.schema))
            else:
                res[f.old_name] = (f.get(instance, schema=self.schema))
        return res

    def set(self, instance, value, **kwargs):
        if not value:
            return

        # keep evil eval for BBB, but: its a security hole
        # disabled by default
        if config.EVIL_EVAL and type(value) in types.StringTypes:
            #if the value comes as string eval it to a dict
            # XXX attention: use restricted environment instead!
            # this is a potential security hole.
            value = eval(value)

        if getattr(self, 'value_class', None):
            if isinstance(value, self.value_class):
                value = self.valueClass2Raw(value)

        for f in self.Schema().fields():
            if value.has_key(f.old_name):
                v = value[f.old_name]
                isarray = type(v) in ListTypes and len(v) == 2 and type(
                    v[1]) == types.DictType
                if v and isarray:
                    kw = v[1]
                else:
                    kw = {}

                request = instance.REQUEST
                if (v or \
                    f.type == 'lines' and \
                    not ('controller_state' in request and \
                         request['controller_state'].getErrors())):
                    if isarray or (type(v) in ListTypes
                                   and len(v) == 1) and f.type != 'datagrid':
                        f.set(instance, v[0], **kw)
                    else:
                        f.set(instance, v, **kw)

    def get(self, instance, **kwargs):
        res = dict()
        for field in self.Schema().fields():
            res[field.old_name] = field.get(instance, **kwargs)
        if getattr(self, 'value_class', None):
            res = self.raw2ValueClass(res)
        return res

    def raw2ValueClass(self, dict):
        res = self.value_class()
        res.__dict__.update(dict)
        return res

    def setSchema(self, schema):
        self.schema = schema
        self.calcFieldNames()

    def calcFieldNames(self, path=[], force_prefix=False):
        ''' prefixes the field names with the parent field name '''
        _fields = self.Schema()._fields

        for f in self.Schema().fields():
            if not getattr(f, 'prefixed', False) or force_prefix:
                # calcFieldNames are often called several times for the same
                # field, e.g. when copying a schema. We do not want to perform
                # prefixing everytime this method is called. We only want to
                # prefix field names in two cases:
                # a) The first time we process a field
                # b) If calcFieldNames is called recursively on subfields, to
                # apply the correct parent field names to the prefixing of a
                # subfield. In this case we set the paramter force_prefix.
                if not getattr(f, 'prefixed', False):
                    # only set old_name the first time we prefix a field - old_name
                    # is the original field name, that we want to use in all prefixings of a field.
                    f.old_name = f.getName()
                    f.prefixed = 1
                f.__name__ = config.COMPOUND_FIELD_SEPERATOR.join([
                    getattr(field, 'old_name', field.getName())
                    for field in path + [self] + [f]
                ])
                #del _fields[old_name]
                _fields[f.__name__] = f
                if ICompoundField.providedBy(f):
                    f.calcFieldNames(path=path + [self], force_prefix=True)

    def getAccessor(self, instance):
        ''' hook to post-generate the accessors for the subfields
            its a little bit hacky, because we need a special ClassGen here
        '''
        if not getattr(self, 'already_bootstrapped', False):
            fields = self.getFields()
            ClassGen.generateMethods(instance.__class__, self.Schema())
            self.already_bootstrapped = True
        return ObjectField.getAccessor(self, instance)

    def valueClass2Raw(self, value):
        res = dict()
        for k in value.__dict__:
            res[k] = (getattr(value, k), )
        return res

    def getFields(self, ):
        return self.Schema().fields()

    def getField(self, key):
        """ get subfield of @param key"""
        return self.Schema().get(key)

    def __init__(self, name=None, schema=None, **kwargs):
        ObjectField.__init__(self, name, **kwargs)
        if not schema:
            schema = self.schema.copy()
        self.setSchema(schema)
예제 #17
0
from reportlab.pdfgen import canvas
from reportlab.lib import colors
from reportlab.lib.units import inch
from reportlab.lib.utils import ImageReader
from reportlab.pdfbase import pdfmetrics

from reportlab.pdfbase.ttfonts import TTFont

##code-section module-header #fill in your manual code here
##/code-section module-header

schema = Schema(
    (
        IntegerField(
            name="pageNo",
            widget=IntegerField._properties["widget"](
                label="Pageno", label_msgid="Newspaper_label_pageNo", i18n_domain="Newspaper"
            ),
        ),
    )
)

##code-section after-local-schema #fill in your manual code here
##/code-section after-local-schema

Webpage_schema = OrderedBaseFolderSchema.copy() + schema.copy()

##code-section after-schema #fill in your manual code here
##/code-section after-schema
# class M_Webpage(NewsFolder.__class__): pass

class PackSlotGenerator(SlotGenerator):
    _slot_class = PackSlot

    def Title(self):
        ''' Just in case we get indexed anyway.'''
        return ''


InitializeClass(PackSlotGenerator)

pc_schema = MinimalSchema + Schema(
    (StringField('layout',
                 accessor='getLayout',
                 mutator='setLayout',
                 vocabulary='_availableLayouts',
                 enforceVocabulary=True,
                 widget=SelectionWidget(label='Layout')),
     StringField('template_path',
                 accessor='getTemplatePath',
                 mutator='setTemplatePath',
                 write_permission=DesignCompo,
                 widget=StringWidget(label='Template Path'))))


class PackComposite(Composite, BaseFolderMixin):
    """ """

    slots = PackSlotGenerator()
    security = ClassSecurityInfo()
    meta_type = portal_type = archetype_name = 'Pack Composite'
    filter_content_types = 1
    allowed_content_types = ('Pack Slot Collection', 'Pack Title Collection',
예제 #19
0
# This field keep track if the field hidden has been set manually or not. If
# this value is false, the system will assume the visibility of this analysis
# in results report will depend on the value set at AR, Profile or Template
# levels (see AnalysisServiceSettings fields in AR). If the value for this
# field is set to true, the system will assume the visibility of the analysis
# will only depend on the value set for the field Hidden (bool).
HiddenManually = BooleanField(
    'HiddenManually',
    default=False,
)

schema = schema.copy() + Schema((
    IsReflexAnalysis,
    OriginalReflexedAnalysis,
    ReflexAnalysisOf,
    ReflexRuleAction,
    ReflexRuleActionsTriggered,
    ReflexRuleLocalID,
    Uncertainty,
    HiddenManually,
))


class AbstractRoutineAnalysis(AbstractAnalysis, ClientAwareMixin):
    implements(IAnalysis, IRequestAnalysis, IRoutineAnalysis, ICancellable)
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema

    @security.public
    def getRequest(self):
        """Returns the Analysis Request this analysis belongs to.
예제 #20
0
from AccessControl import ClassSecurityInfo
from App.class_init import InitializeClass
from Acquisition import aq_base
from Acquisition import aq_inner
from ExtensionClass import Base
from zope.interface import implements

TemplateMixinSchema = Schema((
    # TemplateMixin
    StringField(
        'layout',
        write_permission=permissions.ModifyPortalContent,
        default_method="getDefaultLayout",
        vocabulary="_voc_templates",
        widget=SelectionWidget(
            label=_(u'label_template_mixin', default=u'View template'),
            description=_(
                u'help_template_mixin',
                default=
                u'Choose a template that will be used for viewing this item.'),
            visible={
                'view': 'hidden',
                'edit': 'visible'
            },
        )), ))


class TemplateMixin(Base):
    implements(ITemplateMixin)

    schema = TemplateMixinSchema
예제 #21
0
    ),
)

# Attributes = IdentifierTypeAttributesField(
#     'Attributes',
#     widget=BikaRecordsWidget(
#         label=_("Identifier attributes"),
#         description=_("Each item identified with this IdentifierType can "
#                       "contain additional information.  The allowed
# attributes "
#                       "can be specified here."),
#     ),
# )

schema = BikaSchema.copy() + Schema((
    PortalTypes,
    # Attributes,
))
schema['description'].widget.visible = True
schema['description'].schemata = 'default'


class IdentifierType(BaseContent):
    implements(IDeactivable)
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema

    _at_rename_after_creation = True

    def _renameAfterCreation(self, check_auto_id=False):
        from bika.lims.idserver import renameAfterCreation
from Products.Archetypes.Schema import Schema
from Products.Archetypes.atapi import registerType
from bika.lims import workflow as wf
from bika.lims.catalog.analysisrequest_catalog import \
    CATALOG_ANALYSIS_REQUEST_LISTING
from bika.lims.interfaces import IAnalysisRequest
from senaite.storage import PRODUCT_NAME
from senaite.storage import api
from senaite.storage.content.storagelayoutcontainer import \
    StorageLayoutContainer
from senaite.storage.content.storagelayoutcontainer import schema
from senaite.storage.interfaces import IStorageSamplesContainer
from zope.interface import implements

schema = schema.copy() + Schema((
))


class StorageSamplesContainer(StorageLayoutContainer):
    """Container for the storage of samples
    """
    implements(IStorageSamplesContainer)
    schema = schema
    default_samples_capacity = 1

    def is_object_allowed(self, object_brain_uid):
        """Returns whether the type of object can be stored or not in this
        container. This function returns true if the object is allowed, even
        if the container already contains the object
        """
        # TODO Filer by sample type, volume, etc.
예제 #23
0
    write_permission=FieldEditAnalysisResult,
    schemata='Method',
    widget=RecordsWidget(
        label=_("Calculation Interim Fields"),
        description=_(
            "Values can be entered here which will override the defaults "
            "specified in the Calculation Interim Fields."),
    ))

schema = schema.copy() + Schema((
    AnalysisService,
    Analyst,
    Attachment,
    DetectionLimitOperand,
    # NumberOfRequiredVerifications overrides AbstractBaseClass
    NumberOfRequiredVerifications,
    Result,
    ResultCaptureDate,
    RetestOf,
    Uncertainty,
    Calculation,
    InterimFields))


class AbstractAnalysis(AbstractBaseAnalysis):
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema

    @deprecated('[1705] Currently returns the Analysis object itself.  If you '
                'need to get the service, use getAnalysisService instead')
class ExtensibleMetadata(Persistence.Persistent):
    """ A DC metadata implementation for Plone Archetypes
    """

    implements(IExtensibleMetadata)

    security = ClassSecurityInfo()

    schema = type = MetadataSchema((
        BooleanField(
            'allowDiscussion',
            accessor="isDiscussable",
            mutator="allowDiscussion",
            edit_accessor="editIsDiscussable",
            default=None,
            enforceVocabulary=1,
            widget=BooleanWidget(
                label=_(u'label_allow_comments', default=u'Allow comments'),
                description=_(u'help_allow_comments',
                              default=u'If selected, users can add comments '
                              'to this item.')),
        ),
        LinesField(
            'subject',
            multiValued=1,
            accessor="Subject",
            searchable=True,
            widget=TagsWidget(
                label=_(u'label_tags', default=u'Tags'),
                description=_(u'help_tags',
                              default=u'Tags are commonly used for ad-hoc '
                              'organization of content.'),
            ),
        ),
        TextField(
            'description',
            default='',
            searchable=1,
            accessor="Description",
            default_content_type='text/plain',
            allowable_content_types=('text/plain', ),
            widget=TextAreaWidget(
                label=_(u'label_description', default=u'Description'),
                description=_(
                    u'help_description',
                    default=u'Used in item listings and search results.'),
            ),
        ),
        # Location, also known as Coverage in the DC metadata standard, but we
        # keep the term Location here for historical reasons.
        StringField(
            'location',
            # why no accessor? http://dev.plone.org/plone/ticket/6424
            searchable=True,
            widget=StringWidget(
                label=_(u'label_location', default=u'Location'),
                description=_(
                    u'help_location_dc',
                    default=
                    u'The geographical location associated with the item, if applicable.'
                ),
            ),
        ),
        LinesField(
            'contributors',
            accessor="Contributors",
            widget=AjaxSelectWidget(
                label=_(u'label_contributors', u'Contributors'),
                description=_(
                    u'help_contributors',
                    default=u"The names of people that have contributed "
                    "to this item. Each contributor should "
                    "be on a separate line."),
                vocabulary="plone.app.vocabularies.Users"),
        ),
        LinesField(
            'creators',
            accessor="Creators",
            widget=AjaxSelectWidget(
                label=_(u'label_creators', u'Creators'),
                description=_(
                    u'help_creators',
                    default=u"Persons responsible for creating the content of "
                    "this item. Please enter a list of user names, one "
                    "per line. The principal creator should come first."),
                vocabulary="plone.app.vocabularies.Users"),
        ),
        DateTimeField(
            'effectiveDate',
            mutator='setEffectiveDate',
            languageIndependent=True,
            widget=DatetimeWidget(
                label=_(u'label_effective_date', u'Publishing Date'),
                description=_(
                    u'help_effective_date',
                    default=u"The date when the item will be published. If no "
                    "date is selected the item will be published immediately."
                ),
            ),
        ),
        DateTimeField(
            'expirationDate',
            mutator='setExpirationDate',
            languageIndependent=True,
            widget=DatetimeWidget(
                label=_(u'label_expiration_date', u'Expiration Date'),
                description=_(
                    u'help_expiration_date',
                    default=
                    u"The date when the item expires. This will automatically "
                    "make the item invisible for others at the given date. "
                    "If no date is chosen, it will never expire."),
            ),
        ),
        StringField(
            'language',
            accessor="Language",
            default=config.LANGUAGE_DEFAULT,
            default_method='defaultLanguage',
            vocabulary='languages',
            widget=SelectWidget(label=_(u'label_language',
                                        default=u'Language'), ),
        ),
        TextField(
            'rights',
            accessor="Rights",
            default_method='defaultRights',
            allowable_content_types=('text/plain', ),
            widget=TextAreaWidget(
                label=_(u'label_copyrights', default=u'Rights'),
                description=_(
                    u'help_copyrights',
                    default=
                    u'Copyright statement or other rights information on this item.'
                ),
            )),
    )) + Schema((
        # XXX change this to MetadataSchema in AT 1.4
        # Currently we want to stay backward compatible without migration
        # between beta versions so creation and modification date are using the
        # standard schema which leads to AttributeStorage
        DateTimeField(
            'creation_date',
            accessor='created',
            mutator='setCreationDate',
            default_method=DateTime,
            languageIndependent=True,
            isMetadata=True,
            schemata='metadata',
            generateMode='mVc',
            widget=DatetimeWidget(
                label=_(u'label_creation_date', default=u'Creation Date'),
                description=_(u'help_creation_date',
                              default=u'Date this object was created'),
                visible={
                    'edit': 'invisible',
                    'view': 'invisible'
                }),
        ),
        DateTimeField(
            'modification_date',
            accessor='modified',
            mutator='setModificationDate',
            default_method=DateTime,
            languageIndependent=True,
            isMetadata=True,
            schemata='metadata',
            generateMode='mVc',
            widget=DatetimeWidget(
                label=_(u'label_modification_date',
                        default=u'Modification Date'),
                description=_(u'help_modification_date',
                              default=u'Date this content was modified last'),
                visible={
                    'edit': 'invisible',
                    'view': 'invisible'
                }),
        ),
    ))

    def __init__(self):
        pass

    security.declarePrivate('defaultLanguage')

    def defaultLanguage(self):
        """Retrieve the default language"""
        tool = getToolByName(self, 'portal_languages', None)
        if tool is not None:
            return tool.getDefaultLanguage()
        return config.LANGUAGE_DEFAULT

    security.declarePrivate('defaultRights')

    def defaultRights(self):
        """Retrieve the default rights"""
        mdtool = getToolByName(self, 'portal_metadata', None)
        if mdtool is None:
            return ''
        for sid, schema in mdtool.listSchemas():
            if not hasattr(schema, 'listPolicies'):
                # Broken class from CMFDefault.
                continue
            for pid, policy in schema.listPolicies(typ=self.Type()):
                if pid != 'Rights' and not policy.supply_default:
                    continue
                return policy.default_value
        return ''

    security.declareProtected(permissions.View, 'isDiscussable')

    def isDiscussable(self, encoding=None):
        log_deprecated(
            "The isDiscussable method from the ExtensibleMetadata in "
            "Products.ATContentTypes has been deprecated and will be removed "
            "in Plone 5. This method belongs to the old discussion "
            "infrastructure that already has been replaced by "
            "plone.app.discussion in Plone 4.1.")
        if not 'portal_discussion' in self.objectIds():
            return
        # Returns either True or False
        dtool = getToolByName(self, 'portal_discussion')
        return dtool.isDiscussionAllowedFor(self)

    security.declareProtected(permissions.View, 'editIsDiscussable')

    def editIsDiscussable(self, encoding=None):
        log_deprecated(
            "The editIsDiscussable method from the ExtensibleMetadata in "
            "Products.ATContentTypes has been deprecated and will be removed "
            "in Plone 5. This method belongs to the old discussion "
            "infrastructure that already has been replaced by "
            "plone.app.discussion in Plone 4.1.")
        if not 'portal_discussion' in self.objectIds():
            return
        # Returns True, False or if None the default value
        result = self.rawIsDiscussable()
        if result is not None:
            return result
        default = self.defaultIsDiscussable()
        return default

    security.declareProtected(permissions.View, 'rawIsDiscussable')

    def rawIsDiscussable(self):
        log_deprecated(
            "The rawIsDiscussable method from the ExtensibleMetadata in "
            "Products.ATContentTypes has been deprecated and will be removed "
            "in Plone 5. This method belongs to the old discussion "
            "infrastructure that already has been replaced by "
            "plone.app.discussion in Plone 4.1.")
        if not 'portal_discussion' in self.objectIds():
            return
        # Returns True, False or None where None means use the default
        result = getattr(aq_base(self), 'allow_discussion', None)
        if result is not None:
            result = bool(result)
        return result

    security.declareProtected(permissions.View, 'defaultIsDiscussable')

    def defaultIsDiscussable(self):
        log_deprecated(
            "The defaultIsDiscussable method from the ExtensibleMetadata in "
            "Products.ATContentTypes has been deprecated and will be removed "
            "in Plone 5. This method belongs to the old discussion "
            "infrastructure that already has been replaced by "
            "plone.app.discussion in Plone 4.1.")
        if not 'portal_discussion' in self.objectIds():
            return
        # Returns the default value, either True or False
        default = None
        typeInfo = self.getTypeInfo()
        if typeInfo:
            default = typeInfo.allowDiscussion()
        return default

    security.declareProtected(permissions.ModifyPortalContent,
                              'allowDiscussion')

    def allowDiscussion(self, allowDiscussion=None, **kw):
        pass

    # Vocabulary methods ######################################################

    security.declareProtected(permissions.View, 'languages')

    def languages(self):
        """Vocabulary method for the language field
        """
        util = None

        use_combined = False
        # Respect the combined language code setting from PloneLanguageTool
        lt = getToolByName(self, 'portal_languages', None)
        if lt is not None:
            use_combined = lt.use_combined_language_codes

        # Try the utility first
        if HAS_PLONE_I18N:
            util = queryUtility(IMetadataLanguageAvailability)
        # Fall back to acquiring availableLanguages
        if util is None:
            languages = getattr(self, 'availableLanguages', None)
            if callable(languages):
                languages = languages()
            # Fall back to static definition
            if languages is None:
                return DisplayList(
                    (('en', 'English'), ('fr', 'French'), ('es', 'Spanish'),
                     ('pt', 'Portuguese'), ('ru', 'Russian')))
        else:
            languages = util.getLanguageListing(combined=use_combined)
            languages.sort(key=lambda x: x[1])
            # Put language neutral at the top.
            languages.insert(0, (u'', _(u'Language neutral')))
        return DisplayList(languages)

    #  DublinCore interface query methods #####################################

    security.declareProtected(permissions.View, 'CreationDate')

    def CreationDate(self, zone=None):
        """ Dublin Core element - date resource created.
        """
        if zone is None:
            zone = _zone
        creation = self.getField('creation_date').get(self)
        # return unknown if never set properly
        return creation is None and 'Unknown' or creation.toZone(
            zone).ISO8601()

    security.declareProtected(permissions.View, 'EffectiveDate')

    def EffectiveDate(self, zone=None):
        """ Dublin Core element - date resource becomes effective.
        """
        if zone is None:
            zone = _zone
        effective = self.getField('effectiveDate').get(self)
        return effective is None and 'None' or effective.toZone(zone).ISO8601()

    def _effective_date(self):
        """Computed attribute accessor
        """
        return self.getField('effectiveDate').get(self)

    security.declareProtected(permissions.View, 'effective_date')
    effective_date = ComputedAttribute(_effective_date, 1)

    security.declareProtected(permissions.View, 'ExpirationDate')

    def ExpirationDate(self, zone=None):
        """Dublin Core element - date resource expires.
        """
        if zone is None:
            zone = _zone
        expires = self.getField('expirationDate').get(self)
        return expires is None and 'None' or expires.toZone(zone).ISO8601()

    def _expiration_date(self):
        """Computed attribute accessor
        """
        return self.getField('expirationDate').get(self)

    security.declareProtected(permissions.View, 'expiration_date')
    expiration_date = ComputedAttribute(_expiration_date, 1)

    security.declareProtected(permissions.View, 'Date')

    def Date(self, zone=None):
        """
        Dublin Core element - default date
        """
        # Return effective_date if specifically set, modification date
        # otherwise
        if zone is None:
            zone = _zone
        effective = self.getField('effectiveDate').get(self)
        if effective is None:
            effective = self.modified()
        return (effective is None and DateTime().toZone(zone)
                or effective.toZone(zone).ISO8601())

    security.declareProtected(permissions.View, 'Format')

    def Format(self):
        """cmf/backward compat
        Dublin Core element - resource format
        """
        # FIXME: get content type from marshaller
        return self.getContentType()

    security.declareProtected(permissions.ModifyPortalContent, 'setFormat')

    def setFormat(self, value):
        """cmf/backward compat: ignore setFormat"""
        self.setContentType(value)

    def Identifer(self):
        """ dublin core getId method"""
        return self.getId()

    #  DublinCore utility methods #############################################

    security.declareProtected(permissions.View, 'contentEffective')

    def contentEffective(self, date):
        """Is the date within the resource's effective range?
        """
        effective = self.getField('effectiveDate').get(self)
        expires = self.getField('expirationDate').get(self)
        pastEffective = (effective is None or effective <= date)
        beforeExpiration = (expires is None or expires >= date)
        return pastEffective and beforeExpiration

    security.declareProtected(permissions.View, 'contentExpired')

    def contentExpired(self, date=None):
        """ Is the date after resource's expiration """
        if not date:
            date = DateTime()
        expires = self.getField('expirationDate').get(self)
        if not expires:
            expires = CEILING_DATE
        return expires <= date

    #  CatalogableDublinCore methods ##########################################

    security.declareProtected(permissions.View, 'created')

    def created(self):
        """Dublin Core element - date resource created,
        returned as DateTime.
        """
        # allow for non-existent creation_date, existed always
        created = self.getField('creation_date').get(self)
        return created is None and FLOOR_DATE or created

    security.declareProtected(permissions.View, 'modified')

    def modified(self):
        """Dublin Core element - date resource last modified,
        returned as DateTime.
        """
        modified = self.getField('modification_date').get(self)
        # TODO may return None
        return modified

    security.declareProtected(permissions.View, 'effective')

    def effective(self):
        """Dublin Core element - date resource becomes effective,
        returned as DateTime.
        """
        effective = self.getField('effectiveDate').get(self)
        return effective is None and FLOOR_DATE or effective

    security.declareProtected(permissions.View, 'expires')

    def expires(self):
        """Dublin Core element - date resource expires,
        returned as DateTime.
        """
        expires = self.getField('expirationDate').get(self)
        return expires is None and CEILING_DATE or expires

    ## code below come from CMFDefault.DublinCore.DefaultDublinCoreImpl #######

    ###########################################################################
    #
    # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved
    #
    # This software is subject to the provisions of the Zope Public License,
    # Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
    # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
    # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
    # FOR A PARTICULAR PURPOSE
    #
    ###########################################################################

    #
    #  Set-modification-date-related methods.
    #  In DefaultDublinCoreImpl for lack of a better place.
    #

    security.declareProtected(permissions.ModifyPortalContent,
                              'notifyModified')

    def notifyModified(self):
        """
        Take appropriate action after the resource has been modified.
        For now, change the modification_date.
        """
        self.setModificationDate(DateTime())
        if shasattr(self, 'http__refreshEtag'):
            self.http__refreshEtag()

    security.declareProtected(permissions.ManagePortal, 'setModificationDate')

    def setModificationDate(self, modification_date=None):
        """Set the date when the resource was last modified.
        When called without an argument, sets the date to now.
        """
        if modification_date is None:
            modified = DateTime()
        else:
            modified = self._datify(modification_date)
        self.getField('modification_date').set(self, modified)

    security.declareProtected(permissions.ManagePortal, 'setCreationDate')

    def setCreationDate(self, creation_date=None):
        """Set the date when the resource was created.
        When called without an argument, sets the date to now.
        """
        if creation_date is None:
            created = DateTime()
        else:
            created = self._datify(creation_date)
        self.getField('creation_date').set(self, created)

    security.declarePrivate('_datify')

    def _datify(self, date):
        """Try to convert something into a DateTime instance or None
        """
        # stupid web
        if date == 'None':
            date = None
        if not isinstance(date, DateTime):
            if date is not None:
                date = DateTime(date)
        return date

    #
    #  DublinCore interface query methods
    #
    security.declareProtected(permissions.View, 'Publisher')

    def Publisher(self):
        """Dublin Core element - resource publisher
        """
        # XXX: fixme using 'portal_metadata'
        return 'No publisher'

    security.declareProtected(permissions.View, 'ModificationDate')

    def ModificationDate(self, zone=None):
        """ Dublin Core element - date resource last modified.
        """
        if zone is None:
            zone = _zone
        modified = self.modified()
        return (modified is None and DateTime().toZone(zone)
                or modified.toZone(zone).ISO8601())

    security.declareProtected(permissions.View, 'Type')

    def Type(self):
        """Dublin Core element - Object type"""
        if hasattr(aq_base(self), 'getTypeInfo'):
            ti = self.getTypeInfo()
            if ti is not None:
                return ti.Title()
        return self.meta_type

    security.declareProtected(permissions.View, 'Identifier')

    def Identifier(self):
        """Dublin Core element - Object ID"""
        # XXX: fixme using 'portal_metadata' (we need to prepend the
        #      right prefix to self.getPhysicalPath().
        return self.absolute_url()

    security.declareProtected(permissions.View, 'listContributors')

    def listContributors(self):
        """Dublin Core element - Contributors"""
        return self.Contributors()

    security.declareProtected(permissions.ModifyPortalContent, 'addCreator')

    def addCreator(self, creator=None):
        """ Add creator to Dublin Core creators.
        """
        if creator is None:
            mtool = getToolByName(self, 'portal_membership', None)
            if mtool is None:
                return
            creator = mtool.getAuthenticatedMember().getId()

        # call self.listCreators() to make sure self.creators exists
        curr_creators = self.listCreators()
        if creator and not creator in curr_creators:
            self.setCreators(curr_creators + (creator, ))

    security.declareProtected(permissions.View, 'listCreators')

    def listCreators(self):
        """ List Dublin Core Creator elements - resource authors.
        """
        creators = self.Schema()['creators']
        if not creators.get(self):
            # for content created with CMF versions before 1.5
            owner_tuple = self.getOwnerTuple()
            owner_id = owner_tuple and owner_tuple[1]
            if owner_id:
                creators.set(self, (owner_id, ))
            else:
                creators.set(self, ())

        return creators.get(self)

    security.declareProtected(permissions.View, 'Creator')

    def Creator(self):
        """ Dublin Core Creator element - resource author.
        """
        creators = self.listCreators()
        return creators and creators[0] or ''

    #
    #  DublinCore utility methods
    #

    # Deliberately *not* protected by a security declaration
    # See https://dev.plone.org/archetypes/ticket/712
    def content_type(self):
        """ WebDAV needs this to do the Right Thing (TM).
        """
        return self.Format()

    #
    #  CatalogableDublinCore methods
    #

    security.declareProtected(permissions.View, 'getMetadataHeaders')

    def getMetadataHeaders(self):
        """ Return RFC-822-style headers.
        """
        hdrlist = []
        hdrlist.append(('Title', self.Title()))
        hdrlist.append(('Subject', string.join(self.Subject(), ', ')))
        hdrlist.append(('Publisher', self.Publisher()))
        hdrlist.append(('Description', self.Description()))
        hdrlist.append(('Contributors', string.join(self.Contributors(),
                                                    '; ')))
        hdrlist.append(('Creators', string.join(self.Creators(), '; ')))
        hdrlist.append(('Effective_date', self.EffectiveDate()))
        hdrlist.append(('Expiration_date', self.ExpirationDate()))
        hdrlist.append(('Type', self.Type()))
        hdrlist.append(('Format', self.Format()))
        hdrlist.append(('Language', self.Language()))
        hdrlist.append(('Rights', self.Rights()))
        return hdrlist

    #
    #  Management tab methods
    #

    security.declarePrivate('_editMetadata')

    def _editMetadata(
        self,
        title=_marker,
        subject=_marker,
        description=_marker,
        contributors=_marker,
        effective_date=_marker,
        expiration_date=_marker,
        format=_marker,
        language=_marker,
        rights=_marker,
    ):
        """ Update the editable metadata for this resource.
        """
        if title is not _marker:
            self.setTitle(title)
        if subject is not _marker:
            self.setSubject(subject)
        if description is not _marker:
            self.setDescription(description)
        if contributors is not _marker:
            self.setContributors(contributors)
        if effective_date is not _marker:
            self.setEffectiveDate(effective_date)
        if expiration_date is not _marker:
            self.setExpirationDate(expiration_date)
        if format is not _marker:
            self.setFormat(format)
        if language is not _marker:
            self.setLanguage(language)
        if rights is not _marker:
            self.setRights(rights)

    security.declareProtected(permissions.ModifyPortalContent,
                              'manage_metadata')
    manage_metadata = DTMLFile('zmi_metadata', config._www)

    security.declareProtected(permissions.ModifyPortalContent,
                              'manage_editMetadata')

    def manage_editMetadata(
        self,
        title,
        subject,
        description,
        contributors,
        effective_date,
        expiration_date,
        format,
        language,
        rights,
        REQUEST,
    ):
        """ Update metadata from the ZMI.
        """
        self._editMetadata(
            title,
            subject,
            description,
            contributors,
            effective_date,
            expiration_date,
            format,
            language,
            rights,
        )
        REQUEST['RESPONSE'].redirect(self.absolute_url() + '/manage_metadata' +
                                     '?manage_tabs_message=Metadata+updated.')

    security.declareProtected(permissions.ModifyPortalContent, 'editMetadata')

    def editMetadata(
        self,
        title='',
        subject=(),
        description='',
        contributors=(),
        effective_date=None,
        expiration_date=None,
        format='text/html',
        language='en-US',
        rights='',
    ):
        """
        used to be:  editMetadata = WorkflowAction(_editMetadata)
        Need to add check for webDAV locked resource for TTW methods.
        """
        self.failIfLocked()
        self._editMetadata(
            title=title,
            subject=subject,
            description=description,
            contributors=contributors,
            effective_date=effective_date,
            expiration_date=expiration_date,
            format=format,
            language=language,
            rights=rights,
        )
        self.reindexObject()
예제 #25
0
content_type = Schema((

    StringField(
        name='id',
        required=0,  # Still actually required, but the widget will
                     # supply the missing value on non-submits
        mode='rw',
        permission=permission_copy_or_move,
        accessor='getId',
        mutator='setId',
        default=None,
        widget=IdWidget(
            label=_(u'label_short_name', default=u'Short name'),
            description=_(u'help_shortname',
                          default=u'Should not contain spaces, underscores or mixed case. '
                          'Short Name is part of the item\'s web address.'),
            visible={'view': 'invisible'}
        ),
    ),

    StringField(
        name='title',
        required=1,
        searchable=1,
        default='',
        accessor='Title',
        widget=StringWidget(
            label_msgid='label_title',
            visible={'view': 'invisible'},
            i18n_domain='plone',
        ),
    ),

), marshall=RFC822Marshaller())
예제 #26
0
from Products.CompoundField.CompoundField import CompoundField
from Products.CompoundField.testClasses.XPointWidget import XPointWidget
from Products.CompoundField.testClasses.XPoint import XPoint
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.CompoundField.CompoundField import CompoundField
######CompoundField
schema = Schema((
    IntegerField(
        name='x',
        widget=IntegerField._properties['widget'](
            label='X',
            label_msgid='CompoundField_label_x',
            i18n_domain='CompoundField',
        ),
    ),
    IntegerField(
        name='y',
        widget=IntegerField._properties['widget'](
            label='Y',
            label_msgid='CompoundField_label_y',
            i18n_domain='CompoundField',
        ),
    ),
), )


class XPointField(CompoundField):
    """
    """
    ##code-section class-header #fill in your manual code here
    ##/code-section class-header
예제 #27
0
# This field keeps the user_ids of members who verified this analysis.
# After each verification, user_id will be added end of this string
# seperated by comma- ',' .
Verificators = StringField(
    'Verificators',
    default=''
)

schema = schema.copy() + Schema((
    AnalysisService,
    Analyst,
    Attachment,
    DateAnalysisPublished,
    DetectionLimitOperand,
    # NumberOfRequiredVerifications overrides AbstractBaseClass
    NumberOfRequiredVerifications,
    Result,
    ResultCaptureDate,
    ResultDM,
    Retested,
    Uncertainty,
    Verificators
))


class AbstractAnalysis(AbstractBaseAnalysis):
    implements(ISamplePrepWorkflow)
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema
예제 #28
0
    schemata='Method',
    widget=RecordsWidget(
        label=_("Calculation Interim Fields"),
        description=_(
            "Values can be entered here which will override the defaults "
            "specified in the Calculation Interim Fields."),
    )
)

schema = schema.copy() + Schema((
    IsReflexAnalysis,
    OriginalReflexedAnalysis,
    ReflexAnalysisOf,
    ReflexRuleAction,
    ReflexRuleActionsTriggered,
    ReflexRuleLocalID,
    SamplePartition,
    Uncertainty,
    HiddenManually,
    Calculation,
    InterimFields,
))


class AbstractRoutineAnalysis(AbstractAnalysis):
    implements(IAnalysis, IRequestAnalysis, IRoutineAnalysis, ISamplePrepWorkflow)
    security = ClassSecurityInfo()
    displayContentsTab = False
    schema = schema

    @security.public