コード例 #1
0
class Address(object):
    address_type = FieldProperty(IAddress['address_type'])
    line1 = FieldProperty(IAddress['line1'])
    line2 = FieldProperty(IAddress['line2'])
    city = FieldProperty(IAddress['city'])
    country = FieldProperty(IAddress['country'])
    # Uncomment, if you want to try the relationfield
    #    link = FieldProperty(IAddress['link'])

    # allow getSource to proceed
    _Modify_portal_content_Permission = ('Anonymous', )

    def __init__(self,
                 address_type=None,
                 line1=None,
                 line2=None,
                 city=None,
                 country=None,
                 link=None):
        self.address_type = address_type
        self.line1 = line1
        self.line2 = line2
        self.city = city
        self.country = country
        self.link = link
コード例 #2
0
ファイル: widget.py プロジェクト: bendavis78/zope
class HTMLInputWidget(HTMLFormElement):
    zope.interface.implements(interfaces.IHTMLInputWidget)

    readonly = FieldProperty(interfaces.IHTMLInputWidget['readonly'])
    alt = FieldProperty(interfaces.IHTMLInputWidget['alt'])
    accesskey = FieldProperty(interfaces.IHTMLInputWidget['accesskey'])
    onselect = FieldProperty(interfaces.IHTMLInputWidget['onselect'])
コード例 #3
0
ファイル: resources.py プロジェクト: Mahaswami/paco.models
class ApiGatewayMethod(Resource):
    type = "ApiGatewayMethod"
    resource_id = FieldProperty(schemas.IApiGatewayMethod['resource_id'])
    http_method = FieldProperty(schemas.IApiGatewayMethod['http_method'])
    request_parameters = FieldProperty(schemas.IApiGatewayMethod['request_parameters'])
    method_responses = FieldProperty(schemas.IApiGatewayMethod['method_responses'])
    integration = FieldProperty(schemas.IApiGatewayMethod['integration'])

    @property
    def integration_cfn(self):
        return self.integration.cfn_export_dict

    troposphere_props = troposphere.apigateway.Method.props
    cfn_mapping = {
        #"ApiKeyRequired": (bool, False),
        #"AuthorizationScopes": ([basestring], False),
        #"AuthorizerId": (basestring, False),
        #"RequestModels": (dict, False),
        #"RequestValidatorId": (basestring, False),
        "AuthorizationType": 'authorization_type',
        "HttpMethod": 'http_method',
        "Integration": 'integration_cfn',
        #"MethodResponses": 'method_responses',
        "OperationName": 'title',
        "RequestParameters": 'request_parameters',
        # "ResourceId": computed in the template looked up via resource_id
        # "RestApiId": computed in the template
    }
コード例 #4
0
ファイル: bank_account.py プロジェクト: viona/Easyshop
class BankAccount(Item):
    """Holds all relevant informations for direct debit payment method. This is 
    a bank account.
    """
    implements(IBankAccount)
    portal_type = "BankAccount"

    account_number = FieldProperty(IBankAccount["account_number"])
    bank_identification_code = FieldProperty(
        IBankAccount["bank_identification_code"])
    bank_name = FieldProperty(IBankAccount["bank_name"])
    depositor = FieldProperty(IBankAccount["depositor"])

    def Title(self):
        """
        """
        return self.bank_name + " - " + self.account_number

    def displayInfo(self):
        """ returns relevant payment information as dictionary
        """
        return (
            self.account_number,
            self.bank_identification_code,
            self.bank_name,
            self.depositor,
        )
コード例 #5
0
ファイル: iot.py プロジェクト: Mahaswami/paco.models
class DatasetQueryAction(Named):
    filters = FieldProperty(schemas.IDatasetQueryAction['filters'])
    sql_query = FieldProperty(schemas.IDatasetQueryAction['sql_query'])

    def __init__(self, name, __parent__):
        super().__init__(name, __parent__)
        self.filters = []
コード例 #6
0
class Example(Quotation):

    zope.interface.implements(IExample)

    quid = FieldProperty(IExample['quid'])
    pro_quo = FieldProperty(IExample['pro_quo'])
    marker = FieldProperty(IExample['marker'])
コード例 #7
0
class CreditCard(Item):
    """Holds all relevant information of a credit cart.
    """
    implements(ICreditCard)
    portal_type = "CreditCard"

    card_type = FieldProperty(ICreditCard["card_type"])
    card_owner = FieldProperty(ICreditCard["card_owner"])
    card_number = FieldProperty(ICreditCard["card_number"])
    card_expiration_date_month = FieldProperty(
        ICreditCard["card_expiration_date_month"])
    card_expiration_date_year = FieldProperty(
        ICreditCard["card_expiration_date_year"])

    def Title(self):
        """
        """
        return "%s (%s)" % (self.card_number, self.card_type)

    def displayInfo(self):
        """ returns relevant payment information as tuple
        """
        return (
            self.card_type,
            self.card_owner,
            self.card_number,
            "%s/%s" %
            (self.card_expiration_date_month, self.card_expiration_date_year),
        )
コード例 #8
0
ファイル: iot.py プロジェクト: Mahaswami/paco.models
class IoTDataset(Named, StorageRetention):
    container_action = FieldProperty(schemas.IIoTDataset['container_action'])
    query_action = FieldProperty(schemas.IIoTDataset['query_action'])
    content_delivery_rules = FieldProperty(
        schemas.IIoTDataset['content_delivery_rules'])
    triggers = FieldProperty(schemas.IIoTDataset['triggers'])
    version_history = FieldProperty(schemas.IIoTDataset['version_history'])
コード例 #9
0
ファイル: widget.py プロジェクト: nilbacardit26/plone_prova
class HTMLTextAreaWidget(HTMLFormElement):

    rows = FieldProperty(interfaces.IHTMLTextAreaWidget['rows'])
    cols = FieldProperty(interfaces.IHTMLTextAreaWidget['cols'])
    readonly = FieldProperty(interfaces.IHTMLTextAreaWidget['readonly'])
    accesskey = FieldProperty(interfaces.IHTMLTextAreaWidget['accesskey'])
    onselect = FieldProperty(interfaces.IHTMLTextAreaWidget['onselect'])
コード例 #10
0
class AdmUtilUserManagement(Supernode, PluggableAuthentication):
    """Implementation of local UserManagement Utility"""

    implements(IAdmUtilUserManagement, IAdmUtilUserPreferences)
    adapts(IPrincipal)

    serverURL = FieldProperty(IAdmUtilUserManagement['serverURL'])
    baseDN = FieldProperty(IAdmUtilUserManagement['baseDN'])
    useLdap = FieldProperty(IAdmUtilUserManagement['useLdap'])

    #email = FieldProperty(IAdmUtilUserManagement['email'])

    def __init__(self):
        PluggableAuthentication.__init__(self)
        Supernode.__init__(self)
        self.ikRevision = __version__

    def getRequest(self):
        """ this trick will return the request from the working interaction
        see http://wiki.zope.org/zope3/FAQProgramming#how-do-i-get-irequest-object-in-event-handler
        """
        i = getInteraction()  # raises NoInteraction
        for i_request in i.participations:
            if IRequest.providedBy(i_request):
                return i_request
        raise RuntimeError('Could not find current request.')

    # temp. workaround for "user specific timezone" in normal form
    def get_timezone(self):
        """ property getter"""
        try:
            return AdmUtilUserProperties(self.getRequest().principal).timezone
        except KeyError, errText:
            AdmUtilUserProperties(self.getRequest().principal).timezone = u""
コード例 #11
0
ファイル: widget.py プロジェクト: nilbacardit26/plone_prova
class HTMLTextInputWidget(HTMLInputWidget):

    size = FieldProperty(interfaces.IHTMLTextInputWidget['size'])
    maxlength = FieldProperty(interfaces.IHTMLTextInputWidget['maxlength'])
    placeholder = FieldProperty(interfaces.IHTMLTextInputWidget['placeholder'])
    autocapitalize = FieldProperty(
        interfaces.IHTMLTextInputWidget['autocapitalize'])
コード例 #12
0
class CloudWatchLogGroup(Named, CloudWatchLogRetention):
    metric_filters = FieldProperty(
        schemas.ICloudWatchLogGroup["metric_filters"])
    sources = FieldProperty(schemas.ICloudWatchLogGroup["sources"])
    log_group_name = FieldProperty(
        schemas.ICloudWatchLogGroup["log_group_name"])

    def __init__(self, name, __parent__):
        super().__init__(name, __parent__)
        self.metric_filters = MetricFilters('metric_filters', self)
        self.sources = CloudWatchLogSources(name, __parent__)

    def get_log_group_name(self):
        "Return log_group_name if set, otherwise return name"
        if self.log_group_name != '':
            return self.log_group_name
        return self.name

    def get_full_log_group_name(self):
        name = self.get_log_group_name()
        parent = get_parent_by_interface(self, schemas.ICloudWatchLogSet)
        if parent != None:
            return parent.name + '-' + name
        return name

    def resolve_ref(self, ref):
        return self.resolve_ref_obj.resolve_ref(ref)
コード例 #13
0
class MetricTransformation():
    default_value = FieldProperty(
        schemas.IMetricTransformation["default_value"])
    metric_name = FieldProperty(schemas.IMetricTransformation["metric_name"])
    metric_namespace = FieldProperty(
        schemas.IMetricTransformation["metric_namespace"])
    metric_value = FieldProperty(schemas.IMetricTransformation["metric_value"])
コード例 #14
0
class HTMLTextInputWidget(HTMLInputWidget):
    """Base HTML text input widget"""
    size = FieldProperty(IHTMLTextInputWidget['size'])
    maxlength = FieldProperty(IHTMLTextInputWidget['maxlength'])
    placeholder = FieldProperty(IHTMLTextInputWidget['placeholder'])
    autocomplete = FieldProperty(IHTMLTextInputWidget['autocomplete'])
    autocapitalize = FieldProperty(IHTMLTextInputWidget['autocapitalize'])
コード例 #15
0
class IdChooser(Supernode):
    """Implementation of host group entry."""

    implements(IIdChooser)

    wasUsed = FieldProperty(IIdChooser['wasUsed'])
    counter = FieldProperty(IIdChooser['counter'])
    step = FieldProperty(IIdChooser['step'])
    format = FieldProperty(IIdChooser['format'])

    def __init__(self, **data):
        """
        constructor of the object
        """
        Supernode.__init__(self, **data)
        for (name, value) in data.items():
            if name in IIdChooser.names():
                setattr(self, name, value)
        self.ikRevision = __version__

    def canBeDeleted(self):
        """
        a object can be deleted with normal delete permission
        special objects can overload this for special delete rules
        (e.g. IAdmUtilCatHostGroup)
        return True or False
        """
        return not self.wasUsed

    def incrementId(self):
        """return a unique valid id string.
        """
        self.wasUsed = True
        self.counter += self.step
        return self.format % self.counter
コード例 #16
0
class Article:
    """The article object."""

    implements(IArticle)
    author = FieldProperty(IArticle['author'])
    title = FieldProperty(IArticle['title'])
    pages = FieldProperty(IArticle['pages'])
コード例 #17
0
ファイル: form.py プロジェクト: Py-AMS/pyams-zmi
class FormGroupChecker(ObjectDataManagerMixin, Group):
    """Form group checker

    A "group checker" is based on a "checker" component provided by MyAMS, which allows to
    hide or disable a whole fieldset with a checkbox matching a form's field value.
    """

    checker_fieldname = FieldProperty(IFormGroupChecker['checker_fieldname'])
    checker_mode = FieldProperty(IFormGroupChecker['checker_mode'])

    def __init__(self, context, request, parent_form):
        super().__init__(context, request, parent_form)
        name, field = next(iter(self.fields.items()))
        self.checker_fieldname = name
        self.legend = field.field.title
        self.fields[self.checker_fieldname].widget_factory = SingleCheckBoxFieldWidget

    @reify
    def checker_widget(self):
        """Checker widget getter"""
        return self.widgets[self.checker_fieldname]

    @property
    def checker_state(self):
        """Checker state getter"""
        return 'on' if 'selected' in self.checker_widget.value else 'off'
コード例 #18
0
ファイル: iot.py プロジェクト: Mahaswami/paco.models
class IoTPolicy(ApplicationResource):
    policy_json = FieldProperty(schemas.IIoTPolicy['policy_json'])
    variables = FieldProperty(schemas.IIoTPolicy['variables'])

    def get_aws_name(self):
        "Name of the IoT Policy in AWS"
        ne = get_parent_by_interface(self, schemas.INetworkEnvironment)
        env = get_parent_by_interface(self, schemas.IEnvironment)
        app = get_parent_by_interface(self, schemas.IApplication)
        group = get_parent_by_interface(self, schemas.IResourceGroup)
        name_list = [
            'ne',
            ne.name,
            env.name,
            'app',
            app.name,
            group.name,
            self.name,
        ]
        aws_name = smart_join('-', name_list)
        aws_name = aws_name.replace('_', '-').lower()

        # If the generated policy name is > 128 chars, then prefix a hash of the name
        if len(aws_name) > 128:
            name_hash = md5sum(str_data=aws_name)[:8]
            copy_size = -(128 - 9)
            if aws_name[copy_size] != '-':
                name_hash += '-'
            aws_name = name_hash + aws_name[copy_size:]

        return aws_name
コード例 #19
0
class BackupSelectionConditionResourceType(Parent):
    condition_type = FieldProperty(
        schemas.IBackupSelectionConditionResourceType['condition_type'])
    condition_key = FieldProperty(
        schemas.IBackupSelectionConditionResourceType['condition_key'])
    condition_value = FieldProperty(
        schemas.IBackupSelectionConditionResourceType['condition_value'])
コード例 #20
0
class Person(object):
    name = FieldProperty(IPerson['name'])
    address = FieldProperty(IPerson['address'])

    def __init__(self, name=None, address=None):
        self.name = name
        self.address = address
コード例 #21
0
class CategorizableItemDescription(Persistent, Contained):

    zope.interface.implements(interfaces.ICategorizableItemDescription)

    interface = FieldProperty(
        interfaces.ICategorizableItemDescription['interface'])
    label = FieldProperty(interfaces.ICategorizableItemDescription['label'])
コード例 #22
0
ファイル: site.py プロジェクト: nilbacardit26/plone_prova
class SiteControlPanelAdapter(object):

    adapts(IPloneSiteRoot)
    implements(ISiteSchema)

    def __init__(self, context):
        registry = getUtility(IRegistry)
        self.settings = registry.forInterface(ISiteSchema, prefix="plone")

    def get_site_title(self):
        return self.settings.site_title

    def set_site_title(self, value):
        if isinstance(value, str):
            value = value.decode('utf-8')
        self.settings.site_title = value

    def get_webstats_js(self):
        return self.settings.webstats_js

    def set_webstats_js(self, value):
        if isinstance(value, str):
            value = value.decode('utf-8')
        self.settings.webstats_js = value

    site_title = property(get_site_title, set_site_title)
    webstats_js = property(get_webstats_js, set_webstats_js)

    site_logo = FieldProperty(ISiteSchema['site_logo'])
    enable_sitemap = FieldProperty(ISiteSchema['enable_sitemap'])
    exposeDCMetaTags = FieldProperty(ISiteSchema['exposeDCMetaTags'])
コード例 #23
0
class Assignment(base.Assignment):

    # We need to explicitly mark our persistant data for @@images view look-up
    implements(IImagePortlet, IImageScaleTraversable)

    # Make sure default values work correctly migration proof manner
    text = FieldProperty(IImagePortlet["text"])
    headingText = FieldProperty(IImagePortlet["headingText"])

    image = FieldProperty(IImagePortlet["image"])
    image2 = FieldProperty(IImagePortlet["image2"])
    link = FieldProperty(IImagePortlet["link"])

    def __init__(self, **kwargs):
        self.__dict__.update(**kwargs)

    def modified(self):
        """
        plone.namedfield uses this information to refresh image URLs when the content changes

        (cache busting)
        """
        return DateTime(self._p_mtime)

    @property
    def title(self):
        """
        Be smart as what show as the management interface title.
        """
        entries = [self.headingText, u"Image portlet"]
        for e in entries:
            if e:
                return e
コード例 #24
0
class VPC(Named, Deployable):
    "VPC"

    def __init__(self, name, __parent__):
        super().__init__(name, __parent__)
        self.nat_gateway = NATGateways('nat_gateway', self)
        self.vpn_gateway = VPNGateways('vpn_gateway', self)
        self.security_groups = SecurityGroupSets('security_groups', self)
        self.segments = Segments('segments', self)
        self.peering = VPCPeerings('peering', self)

    cidr = FieldProperty(schemas.IVPC["cidr"])
    enable_dns_hostnames = FieldProperty(schemas.IVPC["enable_dns_hostnames"])
    enable_dns_support = FieldProperty(schemas.IVPC["enable_dns_support"])
    enable_internet_gateway = FieldProperty(
        schemas.IVPC["enable_internet_gateway"])
    nat_gateway = FieldProperty(schemas.IVPC["nat_gateway"])
    vpn_gateway = FieldProperty(schemas.IVPC["vpn_gateway"])
    private_hosted_zone = FieldProperty(schemas.IVPC["private_hosted_zone"])
    security_groups = FieldProperty(schemas.IVPC["security_groups"])
    segments = FieldProperty(schemas.IVPC["segments"])
    peering = FieldProperty(schemas.IVPC["peering"])

    def resolve_ref(self, ref):
        if ref.last_part == 'vpc':
            return self
        return self.resolve_ref_obj.resolve_ref(ref)
コード例 #25
0
class HTMLTextAreaWidget(HTMLFormElement):
    """Base HTML textarea widget"""
    rows = FieldProperty(IHTMLTextAreaWidget['rows'])
    cols = FieldProperty(IHTMLTextAreaWidget['cols'])
    readonly = FieldProperty(IHTMLTextAreaWidget['readonly'])
    accesskey = FieldProperty(IHTMLTextAreaWidget['accesskey'])
    onselect = FieldProperty(IHTMLTextAreaWidget['onselect'])
コード例 #26
0
class IAMUserPermissionCodeBuildResource(Parent):
    codebuild = FieldProperty(
        schemas.IIAMUserPermissionCodeBuildResource['codebuild'])
    permission = FieldProperty(
        schemas.IIAMUserPermissionCodeBuildResource['permission'])
    console_access_enabled = FieldProperty(
        schemas.IIAMUserPermissionCodeBuildResource['console_access_enabled'])
コード例 #27
0
class DropdownMenu(TemplateBasedViewletManager, WeightOrderedViewletManager):
    """Dropdown menu"""

    label = FieldProperty(IDropdownMenu['label'])
    status = FieldProperty(IDropdownMenu['status'])
    css_class = FieldProperty(IDropdownMenu['css_class'])
    icon_class = FieldProperty(IDropdownMenu['icon_class'])
コード例 #28
0
class Config(Resource):
    delivery_frequency = FieldProperty(schemas.IConfig["delivery_frequency"])
    global_resources_region = FieldProperty(
        schemas.IConfig["global_resources_region"])
    locations = FieldProperty(schemas.IConfig["locations"])
    s3_bucket_logs_account = FieldProperty(
        schemas.IConfig["s3_bucket_logs_account"])

    def __init__(self, name, __parent__):
        super().__init__(name, __parent__)
        self.locations = []

    def get_accounts(self):
        """
        Resolve the locations field for all accounts.
        If locations is empty, then all accounts are returned.
        """
        if self.locations == []:
            return project['accounts'].values()
        accounts = []
        project = get_parent_by_interface(self, schemas.IProject)
        for location in self.locations:
            account = references.get_model_obj_from_ref(
                location.account, project)
            accounts.append(account)
        return accounts
コード例 #29
0
class ApiGatewayMethodMethodResponse():
    status_code = FieldProperty(
        schemas.IApiGatewayMethodMethodResponse['status_code'])
    response_models = FieldProperty(
        schemas.IApiGatewayMethodMethodResponse['response_models'])
    response_parameters = FieldProperty(
        schemas.IApiGatewayMethodMethodResponse['response_parameters'])
コード例 #30
0
class Service(Component):
    """
    the template instance
    """

    implements(IService)
    shortName = "service"
    port = FieldProperty(IService['port'])
    product = FieldProperty(IService['product'])
    ipprotocol = FieldProperty(IService['ipprotocol'])

    # for ..Contained we have to:
    __name__ = __parent__ = None
    #ikAttr = FieldProperty(IService['ikAttr'])
    wf_pd_dict = {}
    wf_pd_dict[WfPdNagios.id] = WfPdNagios
    AdmUtilWFMC.wf_pd_dict[WfPdNagios.id] = WfPdNagios

    def __init__(self, **data):
        """
        constructor of the object
        """
        Component.__init__(self, **data)
        self.product = u""
        self.ipprotocol = None
        for (name, value) in data.items():
            if name in IService.names():
                setattr(self, name, value)
        self.ikRevision = __version__
コード例 #31
0
ファイル: attribute.py プロジェクト: geektophe/sitebuilder
    def __set__(self, instance, value):
        """
        Attribute value is set
        """
        FieldProperty.__set__(self, instance, value)

        if IEventBroker.providedBy(instance):
            instance.get_event_bus().publish(
                DataChangeEvent(instance, attribute=self.name, value=value))
コード例 #32
0
ファイル: attribute.py プロジェクト: geektophe/sitebuilder
 def __init__(self, field, name=None):
     """
     Fied initialization
     """
     FieldProperty.__init__(self, field, name)
     self.name = field.__name__