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


Python PersistentMapping.PersistentMapping类代码示例

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


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

示例1: TransformDataProvider

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,代码行数:35,代码来源:utils.py

示例2: __init__

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

        self.config.update({'inputs' : {} })
        self.config_metadata.update({
            'inputs' : {
                'key_label' : '',
                'value_label' : '',
                'description' : ''}
            })
开发者ID:Blaastolen,项目名称:Products.Ploneboard,代码行数:11,代码来源:utils.py

示例3: test_mapping_copy

    def test_mapping_copy(self):

        a = PersistentMapping(dict(a=3, b=5))
        b = a.copy()
        c = copy.copy(a)

        assert a == b
        assert a == c
        assert a is not b
        assert a is not c
        assert b is not c

        del a["a"]
        assert b["a"]  # NOT impacted
        assert c["a"]  # NOT impacted
开发者ID:ChrysalisTeam,项目名称:pychronia,代码行数:15,代码来源:ZODB_tests.py

示例4: __init__

    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'}
            })
开发者ID:Blaastolen,项目名称:Products.Ploneboard,代码行数:15,代码来源:text_to_emoticons.py

示例5: __init__

 def __init__(self, id,title=''):
     '''Initialize an instance of the class'''            
     self.id=id            
     self.sampleImage = ''
     self.abstract = ''
     self.keywords = ''        
     self.uniqueName = ''
     self.geometryField = ''
     self.geometryType = ''
     self.title = id
     self.wfsSRS = ''
     self.wmsStyleName = ''
     self.wfsBoundingBox = ''
     self.fields = ''
     self.source = ''
     self.error = ''
     self.wmsQueryable = ''
     self.wmsName = ''
     self.wfsName = ''
     self.wmsSRS = ''
     self.wmsTitle = ''
     self.hasWFSLayer = False
     self.wmsBoundingBox = ''
     self.describeFeatureResponse = ''
     self.availablePermissions = ['Render','Extract']
     self.security = PersistentMapping() # e.g {'Manager':{'Render':0,'Extract':1}}        
     self.wmsXML = ""
     self.wfsXML = ""
     self.organization = ""
     self.reindexObject()
     self._p_changed = 1
开发者ID:BGCX261,项目名称:zmetadata-svn-to-git,代码行数:31,代码来源:MapLayer.py

示例6: __init__

 def __init__(self, id):
     Content.__init__(self, id)
     Query.__init__(self)
     self.shownFields = PersistentMapping()
     self.shownResultsFields = PersistentMapping()
     # by default we only show fulltext search
     # and a couple of resultfields
     self.shownFields['fulltext'] = True
     self.shownResultsFields['link'] = True
     self.shownResultsFields['ranking'] = True
     self.shownResultsFields['resultcount'] = True
     self.shownResultsFields['icon'] = True
     self.shownResultsFields['date'] = True
     self.shownResultsFields['textsnippet'] = True
     self.shownResultsFields['thumbnail'] = True
     self.shownResultsFields['breadcrumbs'] = True
开发者ID:silvacms,项目名称:Products.SilvaFind,代码行数:16,代码来源:SilvaFind.py

示例7: __init__

 def __init__(self,default_role,NoLocalRoles):
     self.id='nisAuthSource'
     self.default_role=default_role
     self.NoLocalRoles=NoLocalRoles
     self.data=PersistentMapping()
     self.manage_addUserForm=DTMLFile('manage_addNISUserForm',globals())
     self.manage_editUserForm=DTMLFile('manage_editNISUserForm',globals()) #not used.  No way to plug it into exUserFolder.py
开发者ID:denys-duchier,项目名称:Scolar,代码行数:7,代码来源:nisAuthSource.py

示例8: Map

class Map(SimpleItem):
    def __init__(self, id):
        self.id = id
        self.channels = PersistentMapping()
        self.policy = defaultPolicy

    def setPolicy(self, name):
        self.policy = lookupPolicy(name, defaultPolicy)

    def setPriority(self, channel, pri):
        if not isinstance(channel, Channel):
            id = channel.id
        else:
            id = channel

        channel = self.channels[id]
        channel['priority'] = int(pri)


    def addChannel(self, channel, **kwargs):
        enabled  = kwargs.get('enabled', 1)
        priority = kwargs.get('priority', 0)

        self.channels[channel.id] = {'channel' : channel,
                                     'enabled' : enabled,
                                     'priority': priority,
                                     }
    def Channels(self):
        return self.channels.values()
开发者ID:cislgov,项目名称:cisl.portal.plone25,代码行数:29,代码来源:Map.py

示例9: __init__

    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 = {}
开发者ID:tuxwerk,项目名称:Products.csvreplicata,代码行数:8,代码来源:csvreplicataTool.py

示例10: __init__

    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",
                }
            }
        )
开发者ID:a25kk,项目名称:stv2,代码行数:18,代码来源:text_to_emoticons.py

示例11: EmoticonDataProvider

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,代码行数:41,代码来源:text_to_emoticons.py

示例12: EmoticonDataProvider

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,代码行数:36,代码来源:text_to_emoticons.py

示例13: BdrAuthorizationMiddleware

class BdrAuthorizationMiddleware(SimpleItem):

    recheck_interval = 300

    def __init__(self, url):
        self.recheck_interval = 300
        self.lockedDownCollections = PersistentMapping()

    def setServiceRecheckInterval(self, seconds):
        self.recheck_interval = seconds

    @ram.cache(lambda *args, **kwargs: args[2] + str(time() // kwargs['recheck_interval']))
    def getUserCollectionPaths(self, username, recheck_interval=recheck_interval):
        logger.debug("Get companies from middleware for ecas user: %s" % username)
        accessiblePaths = self.FGASRegistryAPI.getCollectionPaths(username)
        return accessiblePaths

    def authorizedUser(self, username, path):
        if self.lockedCollection(path):
            logger.warning("This collection is locked down: %s!" % path)
            return False
        accessiblePaths = self.getUserCollectionPaths(username, recheck_interval=self.recheck_interval)
        if path in accessiblePaths.get('paths'):
            return "RW"
        if path in accessiblePaths.get('prev_paths'):
            return "RO"

    def lockDownCollection(self, path, user):
        if path not in self.lockedDownCollections:
            self.lockedDownCollections[path] = None
        self.lockedDownCollections[path] = {'state': 'locked',
                                            'ts': time(),
                                            'user': user}

    def unlockCollection(self, path, user):
        if path not in self.lockedDownCollections:
            # log unlock without lock
            self.lockedDownCollections[path] = None
        self.lockedDownCollections[path] = {'state': 'unlocked',
                                            'ts': time(),
                                            'user': user}

    def lockedCollection(self, path):
        lockedItem = self.lockedDownCollections.get(path)
        return lockedItem and lockedItem['state'] == 'locked'
开发者ID:eea,项目名称:Products.Reportek,代码行数:45,代码来源:BdrAuthorizationMiddleware.py

示例14: Query

class Query(object):

    def __init__(self):
        self.searchValues = PersistentMapping()

    def getSearchSchema(self):
        return getUtility(IFindService).getSearchSchema()

    def getResultsSchema(self):
        return getUtility(IFindService).getResultsSchema()

    def getSearchFields(self):
        return self.getSearchSchema().getFields()

    def getResultFields(self):
        return self.getResultsSchema().getFields()

    def getCriterionValue(self, name):
        searchSchema = self.getSearchSchema()
        if searchSchema.hasField(name):
            return self.searchValues.get(name, None)
        else:
            raise ValueError(
                u'No field named %s defined in search schema' %
                name)

    def deleteCriterionValue(self, name):
        searchSchema = self.getSearchSchema()
        if searchSchema.hasField(name):
            if name in self.searchValues:
                del self.searchValues[name]

    def setCriterionValue(self, name, value):
        searchSchema = self.getSearchSchema()
        if searchSchema.hasField(name):
            self.searchValues[name] = value
        else:
            raise ValueError(
                u'No field named %s defined in search schema' %
                name)
开发者ID:silvacms,项目名称:Products.SilvaFind,代码行数:40,代码来源:query.py

示例15: Themes

class Themes(SimpleItem, session_manager):
    """ Themes """

    meta_type = THEMES_METATYPE
    product_name = NAAYATHESAURUS_PRODUCT_NAME
    icon = "misc_/NaayaThesaurus/themes.gif"

    manage_options = (
        {"label": "Basic properties", "action": "properties_html"},
        {"label": "Management", "action": "themes_html"},
        {"label": "Import", "action": "import_html"},
        {"label": "Statistics", "action": "statistics_html"},
        {"label": "Undo", "action": "manage_UndoForm"},
    )

    security = ClassSecurityInfo()

    def __init__(self, id, title):
        """ constructor """
        self.id = id
        self.title = title
        self.themes = PersistentMapping()

    # basic properties
    security.declareProtected(view_management_screens, "manageBasicProperties")

    def manageBasicProperties(self, title="", REQUEST=None):
        """ manage basic properties for Themes """
        self.title = title
        self._p_changed = 1
        if REQUEST:
            self.setSessionInfoTrans("Saved changes.")
            return REQUEST.RESPONSE.redirect("properties_html")

    # themes management
    def __add_theme(self, theme_id, langcode, name):
        # create a new item
        item = ThemeItem(theme_id, langcode, name)
        self.themes[(theme_id, langcode)] = item
        self.catalog.CatalogObject(item)

    def __update_theme(self, theme_id, old_theme_id, langcode, old_langcode, name):
        # modify an item
        item = self.themes.get((old_theme_id, old_langcode))
        if item is not None:
            self.__delete_theme((old_theme_id, old_langcode))
        self.__add_theme(theme_id, langcode, name)

    def __delete_theme(self, ids):
        # delete 1 or more items
        if type(ids) != type((1, 1)):
            ids = th_utils().utConvertToList(ids)
        else:
            ids = [ids]
        collection = self.get_themes()

        for id in ids:
            self.catalog.UncatalogObject(collection[id])
            del collection[id]

    # theme constraints
    security.declareProtected(view_management_screens, "checkTheme")

    def checkTheme(self, theme_id):
        """ """
        if theme_id in self.getThemeRelationsFolder().getDistinctThemes():
            return 1
        return 0

    security.declareProtected(view_management_screens, "getIdsList")

    def getIdsList(self, ids, all=0):
        """ """
        if all:
            return self.themes.keys()
        return th_utils().getIdsList(ids)

    # themes getters
    def get_themes(self):
        # get all themes
        return self.themes

    def get_themes_sorted(self):
        # get all themes sorted
        return th_utils().utSortObjsListByAttr(self.themes.values(), "langcode", 0)

    def get_theme_by_id(self, id):
        # get an item
        try:
            return self.themes[id]
        except:
            return None

    def get_theme_item_data(self, theme_id, langcode, orig_theme_id, orig_langcode, theme_name):
        # get an item data
        item = self.get_theme_by_id((orig_theme_id, orig_langcode))
        if item is not None:
            if theme_name is None:
                theme_name = item.theme_name
            return ["update", theme_id, langcode, theme_name, orig_theme_id, orig_langcode]
#.........这里部分代码省略.........
开发者ID:eaudeweb,项目名称:naaya.Products.NaayaThesaurus,代码行数:101,代码来源:Themes.py


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