当前位置: 首页>>代码示例>>Python>>正文


Python PersistentMapping.update方法代码示例

本文整理汇总了Python中ZODB.PersistentMapping.PersistentMapping.update方法的典型用法代码示例。如果您正苦于以下问题:Python PersistentMapping.update方法的具体用法?Python PersistentMapping.update怎么用?Python PersistentMapping.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ZODB.PersistentMapping.PersistentMapping的用法示例。


在下文中一共展示了PersistentMapping.update方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TransformDataProvider

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class TransformDataProvider(Implicit):
    """ Base class for data providers """
    security = ClassSecurityInfo()
    security.declareObjectPublic()

    def __init__(self):
        self.config = PersistentMapping()
        self.config_metadata = PersistentMapping()

        self.config.update({'inputs' : {} })
        self.config_metadata.update({
            'inputs' : {
                'key_label' : '',
                'value_label' : '',
                'description' : ''}
            })

    security.declarePublic('setElement')
    def setElement(self, inputs):
        """ inputs - dictionary, but may be extended to new data types"""
        self.config['inputs'].update(inputs)

    def delElement(self, el):
        """ el - dictionary key"""
        del self.config['inputs'][el]

    security.declarePublic('getElements')
    def getElements(self):
        """ Returns mapping """
        return self.config['inputs']

    security.declarePublic('getConfigMetadata')
    def getConfigMetadata(self):
        """ Returns config metadata """
        return self.config_metadata['inputs']
开发者ID:Blaastolen,项目名称:Products.Ploneboard,代码行数:37,代码来源:utils.py

示例2: EmoticonDataProvider

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class EmoticonDataProvider(TransformDataProvider):
    def __init__(self):
        """ We need to redefine config and config_metadata
        in base class.
        """
        self.config = PersistentMapping()
        self.config_metadata = PersistentMapping()

        self.config.update({"inputs": self.defaultEmoticons()})

        self.config_metadata.update(
            {
                "inputs": {
                    "key_label": "emoticon code",
                    "value_label": "image name",
                    "description": "Emoticons to images mapping",
                }
            }
        )

    def defaultEmoticons():
        emoticons = {
            ":)": '<img src="smiley_smile.png" alt=":)" title="Smile" />',
            ":(": '<img src="smiley_sad.png" alt=":(" title="Sad" />',
            "8-)": '<img src="smiley_cool.png" alt="8)" title="Cool" />',
            ":D": '<img src="smiley_lol.png" alt=":D" title="Big grin" />',
            ":|": '<img src="smiley_skeptic.png" alt=":|" title="Skeptic" />',
            ":o": '<img src="smiley_surprised.png" alt=":o" title="Surprised" />',
            ":P": '<img src="smiley_tongue.png" alt=":P" title="Tongue-in-cheek" />',
            ";)": '<img src="smiley_wink.png" alt=";)" title="Wink" />',
            ":-)": '<img src="smiley_smile.png" alt=":)" title="Smile" />',
            ":-(": '<img src="smiley_sad.png" alt=":(" title="Sad" />',
            ":-D": '<img src="smiley_lol.png" alt=":D" title="Big grin" />',
            ":-|": '<img src="smiley_skeptic.png" alt=":|" title="Skeptic" />',
            ":-o": '<img src="smiley_surprised.png" alt=":o" title="Surprised" />',
            ":-P": '<img src="smiley_tongue.png" alt=":P" title="Tongue-in-cheek" />',
            ";-)": '<img src="smiley_wink.png" alt=";)" title="Wink" />',
        }
        return emoticons

    defaultEmoticons = staticmethod(defaultEmoticons)
开发者ID:a25kk,项目名称:stv2,代码行数:43,代码来源:text_to_emoticons.py

示例3: EmoticonDataProvider

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class EmoticonDataProvider(TransformDataProvider):
    def __init__(self):
        """ We need to redefine config and config_metadata
        in base class.
        """
        self.config = PersistentMapping()
        self.config_metadata = PersistentMapping()
        
        self.config.update({ 'inputs' : self.defaultEmoticons()})

        self.config_metadata.update({
            'inputs' : {
                'key_label' : 'emoticon code', 
                'value_label' : 'image name', 
                'description' : 'Emoticons to images mapping'}
            })

    def defaultEmoticons():
        emoticons = { ':)' : '<img src="smiley_smile.png" alt=":)" title="Smile" />'
                    , ':(' : '<img src="smiley_sad.png" alt=":(" title="Sad" />'
                    , '8-)' : '<img src="smiley_cool.png" alt="8)" title="Cool" />'
                    , ':D' : '<img src="smiley_lol.png" alt=":D" title="Big grin" />'
                    , ':|' : '<img src="smiley_skeptic.png" alt=":|" title="Skeptic" />'
                    , ':o' : '<img src="smiley_surprised.png" alt=":o" title="Surprised" />'
                    , ':P' : '<img src="smiley_tongue.png" alt=":P" title="Tongue-in-cheek" />'
                    , ';)' : '<img src="smiley_wink.png" alt=";)" title="Wink" />'
                    , ':-)' : '<img src="smiley_smile.png" alt=":)" title="Smile" />'
                    , ':-(' : '<img src="smiley_sad.png" alt=":(" title="Sad" />'
                    , ':-D' : '<img src="smiley_lol.png" alt=":D" title="Big grin" />'
                    , ':-|' : '<img src="smiley_skeptic.png" alt=":|" title="Skeptic" />'
                    , ':-o' : '<img src="smiley_surprised.png" alt=":o" title="Surprised" />'
                    , ':-P' : '<img src="smiley_tongue.png" alt=":P" title="Tongue-in-cheek" />'
                    , ';-)' : '<img src="smiley_wink.png" alt=";)" title="Wink" />'
                    }
        return emoticons
    defaultEmoticons=staticmethod(defaultEmoticons)
开发者ID:Blaastolen,项目名称:Products.Ploneboard,代码行数:38,代码来源:text_to_emoticons.py

示例4: PloneKupuLibraryTool

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class PloneKupuLibraryTool(UniqueObject, SimpleItem, KupuLibraryTool,
    plonedrawers.PloneDrawers):
    """Plone specific version of the kupu library tool"""

    id = TOOLNAME
    meta_type = "Kupu Library Tool"
    title = TOOLTITLE
    security = ClassSecurityInfo()
    implements(IPloneKupuLibraryTool)

    # protect methods provided by super class KupuLibraryTool
    security.declareProtected(permissions.QueryLibraries, "getLibraries",
                              "getPortalTypesForResourceType")
    security.declareProtected(permissions.ManageLibraries, "addLibrary",
                              "deleteLibraries", "updateLibraries",
                              "moveUp", "moveDown")
    security.declareProtected(permissions.ManageLibraries, "addResourceType",
                              "updateResourceTypes", "deleteResourceTypes")

    def __init__(self):
        self._libraries = PersistentList()
        self._res_types = PersistentMapping()
        self.linkbyuid = False

    def manage_afterAdd(self, item, container):
        # We load default values here, so __init__ can still be used
        # in unit tests. Plus, it only makes sense to load these if
        # we're being added to a Plone site anyway
        if not len(self._libraries):
            for lib in _default_libraries:
                self.addLibrary(**lib)
            self._res_types.update(_default_resource_types)

    security.declareProtected('View', "getLinkbyuid")
    def getLinkbyuid(self):
        """Returns 'is linking by UID enabled'?"""
        try:
            return bool(self.linkbyuid)
        except AttributeError:
            return False

    security.declareProtected('View', "getRefBrowser")
    def getRefBrowser(self):
        """Returns True if kupu_references is in all skin layers"""
        return util.layer_installed(self, 'kupu_references')

    security.declareProtected(permissions.ManageLibraries, 'ensureReferencesLayer')
    def ensureReferencesLayer(self, add=False):
        """Called from the link tab code: we must have the
        kupu_references directory view at least present for
        the link tab to work."""
        out = StringIO()
        util.register_layer(self, 'plone/kupu_references', 'kupu_references', out, add)

    security.declareProtected('View', "getCaptioning")
    def getCaptioning(self):
        """Returns True if captioning is enabled"""
        try:
            return bool(self.captioning)
        except AttributeError:
            return False

    security.declareProtected('View', "getTableClassnames")
    def getTableClassnames(self):
        """Return a list of classnames supported in tables"""
        try:
            return self.table_classnames
        except AttributeError:
            return ('plain', 'listing', 'vertical listing', 'listing nosort|unsorted listing')

    security.declareProtected('View', "getParagraphStyles")
    def getParagraphStyles(self):
        """Return a list of classnames supported by paragraphs"""
        try:
            return self.paragraph_styles
        except AttributeError:
            return _default_paragraph_styles

    security.declareProtected('View', "getStyleList")
    def getStyleList(self, field=None):
        """Return the styles for a field."""
        gstyles = self.getParagraphStyles()
        if field:
            widget = field.widget
            redefine = getattr(widget, 'redefine_parastyles', False)
            lstyles = getattr(widget, 'parastyles', ())
        else:
            redefine = False
            lstyles = []

        result = []
        __traceback_info__ = (gstyles, lstyles)
        if redefine:
            styles = lstyles
        else:
            styles = list(gstyles) + list(lstyles)
            
        for style in styles:
            parts = style.split('|',1)+['','']
            value = parts[1]
#.........这里部分代码省略.........
开发者ID:nacho22martin,项目名称:tesis,代码行数:103,代码来源:plonelibrarytool.py

示例5: PloneKupuLibraryTool

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class PloneKupuLibraryTool(UniqueObject, SimpleItem, KupuLibraryTool):
    """Plone specific version of the kupu library tool"""

    id = TOOLNAME
    meta_type = "Kupu Library Tool"
    title = TOOLTITLE
    security = ClassSecurityInfo()

    # protect methods provided by super class KupuLibraryTool
    security.declareProtected(permissions.QueryLibraries, "getLibraries",
                              "getPortalTypesForResourceType")
    security.declareProtected(permissions.ManageLibraries, "addLibrary",
                              "deleteLibraries", "updateLibraries",
                              "moveUp", "moveDown")
    security.declareProtected(permissions.ManageLibraries, "addResourceType",
                              "updateResourceTypes", "deleteResourceTypes")

    def __init__(self):
        self._libraries = PersistentList()
        self._res_types = PersistentMapping()
        self.linkbyuid = False

    def manage_afterAdd(self, item, container):
        # We load default values here, so __init__ can still be used
        # in unit tests. Plus, it only makes sense to load these if
        # we're being added to a Plone site anyway
        for lib in _default_libraries:
            self.addLibrary(**lib)
        self._res_types.update(_default_resource_types)

    security.declareProtected('View', "getLinkbyuid")
    def getLinkbyuid(self):
        """Returns 'is linking by UID enabled'?"""
        try:
            return self.linkbyuid
        except AttributeError:
            return 1

    security.declareProtected('View', "getTableClassnames")
    def getTableClassnames(self):
        """Return a list of classnames supported in tables"""
        try:
            return self.table_classnames
        except AttributeError:
            return ('plain', 'listing', 'vertical listing', 'listing nosort|unsorted listing')

    security.declareProtected('View', "getParagraphStyles")
    def getParagraphStyles(self):
        """Return a list of classnames supported by paragraphs"""
        try:
            return self.paragraph_styles
        except AttributeError:
            return _default_paragraph_styles

    security.declareProtected('View', "getHtmlExclusions")
    def getHtmlExclusions(self):
        try:
            return self.html_exclusions
        except AttributeError:
            self.html_exclusions = _excluded_html
            return self.html_exclusions

    security.declareProtected('View', "getStyleWhitelist")
    def getStyleWhitelist(self):
        try:
            return self.style_whitelist
        except AttributeError:
            self.style_whitelist = _style_whitelist
            return self.style_whitelist

    security.declareProtected('View', "getClassBlacklist")
    def getClassBlacklist(self):
        return getattr(self, 'class_blacklist', [])

    security.declareProtected('View', "getClassBlacklist")
    def installBeforeUnload(self):
        return getattr(self, 'install_beforeunload', True)

    security.declareProtected('View', 'isKupuEnabled')
    def isKupuEnabled(self, useragent='', allowAnonymous=False, REQUEST=None):
        def numerics(s):
            '''Convert a string into a tuple of all digit sequences
            '''
            seq = ['']
            for c in s:
                if c.isdigit():
                    seq[-1] = seq[-1] + c
                elif seq[-1]:
                    seq.append('')
            return tuple([ int(val) for val in seq if val])

        # First check whether the user actually wants kupu
        pm = getToolByName(self, 'portal_membership')
        if pm.isAnonymousUser() and not allowAnonymous:
            return False

        user = pm.getAuthenticatedMember()
        if user.getProperty('wysiwyg_editor').lower() != 'kupu':
            return False

#.........这里部分代码省略.........
开发者ID:Freizeitsoldat,项目名称:foswiki,代码行数:103,代码来源:plonelibrarytool.py

示例6: csvreplicataTool

# 需要导入模块: from ZODB.PersistentMapping import PersistentMapping [as 别名]
# 或者: from ZODB.PersistentMapping.PersistentMapping import update [as 别名]
class csvreplicataTool(UniqueObject, BaseContent, BrowserDefaultMixin):
    """
    """
    security = ClassSecurityInfo()
    implements(interfaces.IcsvreplicataTool)

    meta_type = 'csvreplicataTool'
    _at_rename_after_creation = True

    schema = csvreplicataTool_schema

    handlers = PersistentMapping

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




    # tool-constructors have no id argument, the id is fixed
    def __init__(self, id=None):
        BaseContent.__init__(self,'portal_csvreplicatatool')
        self.setTitle('')

        ##code-section constructor-footer #fill in your manual code here
        self.setTitle('CSV Replicator tool')
        self.replicabletypes = PersistentMapping()
        self.handlers = {}
        ##/code-section constructor-footer

    @property
    def dreplicabletypes(self):
        return dict(self.replicabletypes)


    def manage_afterAdd(self, item, container):
        """ initialize handlers with appconfig HANDLERS values"""
        self.handlers = HANDLERS

    # tool should not appear in portal_catalog
    def at_post_edit_script(self):
        self.unindexObject()

        ##code-section post-edit-method-footer #fill in your manual code here
        ##/code-section post-edit-method-footer


    # Methods

    # Manually created methods

    def setCSVsettings(self, REQUEST):
        """
        """
        self.setEncoding(REQUEST.get('encoding'));
        self.setDelimiter(REQUEST.get('delimiter'));
        self.setServerfilepath(REQUEST.get('serverfilepath'));
        self.setDateTimeFormat(REQUEST.get('datetimeformat'));
        self.setTempPath(REQUEST.get('tempPath'))
        self.setPlainFormat(REQUEST.get('is_plain_format', '') == 'on')
        self.setPartialCommitNumber(int(REQUEST.get('partial_commit_number', '')))
        # Redirection of the page now that the treatment is done
        REQUEST.RESPONSE.redirect(self.absolute_url()+'/csv_settings')

    def setCSVHandledTypes(self, REQUEST):
        """
        """
        types_tool = getToolByName(self, 'archetype_tool')

        # Get of the various replicabletypes current and new)
        newreplicabletypes = REQUEST.get('csvhandledtypes')
        if (not type(newreplicabletypes) is list):
            newreplicabletypes = [newreplicabletypes]
        currentreplicablestypes = self.replicabletypes

        # Addition of the new replicable types, by default a new empty list
        # and creation of a temp variable to hold the new csv handled types
        newreplicabletypestempdict = {}
        for t in newreplicabletypes :
            newreplicabletypestempdict[t] = []
            if (not currentreplicablestypes.has_key(t)):
                    currentreplicablestypes[t] = ['default', ]

        # removal of the types that are not anymore replicables
        for k, v in currentreplicablestypes.items():
            if (not newreplicabletypestempdict.has_key(k)):
                del currentreplicablestypes[k]

        # save of the new values
        self.replicabletypes.update(currentreplicablestypes)

        # Redirection of the page now that the treatment is done
        REQUEST.RESPONSE.redirect(self.absolute_url()+'/csv_settings')

    def setExcludedFields(self, REQUEST):
        """
        """
        self.setExcludedfieldsclasses(
            REQUEST.get('excludedfieldsclasses').split('\n'));
        self.setExcludedfields(REQUEST.get('excludedfields').split('\n'));
#.........这里部分代码省略.........
开发者ID:tuxwerk,项目名称:Products.csvreplicata,代码行数:103,代码来源:csvreplicataTool.py


注:本文中的ZODB.PersistentMapping.PersistentMapping.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。