How to use the persistent.interfaces.IPersistent function in persistent

To help you get started, we’ve selected a few persistent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Pylons / substanced / substanced / folder / __init__.py View on Github external
def includeme(config): # pragma: no cover
    # The ICopyHook adapter avoids dumping referenced objects that are not
    # located inside an object containment-wise when that object is copied.  If
    # it is not registered, every copy winds up dumping all the objects in the
    # database due to __parent__ pointers.
    config.registry.registerAdapter(CopyHook, (IPersistent,), ICopyHook)
    config.hook_zca() # required by zope.copy (it uses a global adapter lkup)
    YEAR = 86400 * 365
    config.add_static_view('fcstatic', 'substanced.folder:static',
                           cache_max_age=YEAR)
    config.add_view_predicate('addable_content', _AddableContentPredicate)
    config.include('.views')
    config.include('.evolve')
github zopefoundation / persistent / persistent / persistence.py View on Github external
_SPECIAL_NAMES = set(SPECIAL_NAMES)

# __ring is for use by PickleCachePy and is opaque to us.
_SLOTS = ('__jar', '__oid', '__serial', '__flags', '__size', '__ring',)
_SPECIAL_NAMES.update([intern('_Persistent' + x) for x in _SLOTS])


# Represent 8-byte OIDs as hex integer, just like
# ZODB does.
_OID_STRUCT = struct.Struct('>Q')
_OID_UNPACK = _OID_STRUCT.unpack



@use_c_impl
@implementer(interfaces.IPersistent)
class Persistent(object):
    """ Pure Python implmentation of Persistent base class
    """
    __slots__ = _SLOTS

    def __new__(cls, *args, **kw):
        inst = super(Persistent, cls).__new__(cls)
        # We bypass the __setattr__ implementation of this object
        # at __new__ time, just like the C implementation does. This
        # makes us compatible with subclasses that want to access
        # properties like _p_changed in their setattr implementation
        _OSA(inst, '_Persistent__jar', None)
        _OSA(inst, '_Persistent__oid', None)
        _OSA(inst, '_Persistent__serial', None)
        _OSA(inst, '_Persistent__flags', None)
        _OSA(inst, '_Persistent__size', 0)
github zopefoundation / Zope / lib / python / OFS / interfaces.py View on Github external
context.

        Passing a false value for the validate_src argument will skip
        checking the passed in object in its existing context. This is
        mainly useful for situations where the passed in object has no
        existing context, such as checking an object during an import
        (the object will not yet have been connected to the
        acquisition hierarchy).
        """


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on OFS.ObjectManager.ObjectManager
class IObjectManager(IZopeObject, ICopyContainer, INavigation, IManageable,
                     IAcquirer, IPersistent, IDAVCollection, ITraversable,
                     IPossibleSite):
    """Generic object manager

    This interface provides core behavior for collections of heterogeneous
    objects."""

    meta_types = Tuple(
        title=u"Meta types",
        description=u"Sub-object types that are specific to this object",
        )

    isAnObjectManager = Bool(
        title=u"Is an object manager",
        )

    manage_main = Attribute(""" """)
github collective / collective.solr / src / collective / solr / exportimport.py View on Github external
def exportSolrSettings(context):
    """ export settings for solr integration as an XML file """
    site = context.getSite()
    utility = queryUtility(ISolrConnectionConfig, context=site)
    if utility is None:
        logger = context.getLogger('collective.solr')
        logger.info('Nothing to export.')
        return
    if IPersistent.providedBy(utility):
        exportObjects(utility, '', context)
github zopefoundation / Zope / lib / python / OFS / interfaces.py View on Github external
error_type=None, error_value=None, tb=None,
                                   error_tb=None, error_message='',
                                   tagSearch=None, error_log_url=''):
        """Raise standard error message.
        """


# XXX: based on OFS.SimpleItem.Item_w__name__
class IItemWithName(IItem):

    """Item with name.
    """


# XXX: based on OFS.SimpleItem.SimpleItem
class ISimpleItem(IItem, IPersistent, IAcquirer, IRoleManager):

    """Not-so-simple item.
    """


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on OFS.CopySupport.CopyContainer
class ICopyContainer(Interface):

    """Interface for containerish objects which allow cut/copy/paste"""

    # The following three methods should be overridden to store sub-objects
    # as non-attributes.
    def _setOb(id, object):
        """
github zopefoundation / persistent / persistent / __init__.py View on Github external
from persistent import persistence as pyPersistence
from persistent import picklecache as pyPickleCache

try:
    # Be careful not to shadow the modules
    from persistent import cPersistence as _cPersistence
    from persistent import cPickleCache as _cPickleCache
except ImportError: # pragma: no cover
    _cPersistence = None
    _cPickleCache = None
else:
    # Make an interface declaration for Persistent
    # Note that the Python version already does this.
    from zope.interface import classImplements
    classImplements(_cPersistence.Persistent, IPersistent)
    classImplements(_cPickleCache.PickleCache, IPickleCache)


_persistence = pyPersistence if PURE_PYTHON or _cPersistence is None else _cPersistence
_picklecache = pyPickleCache if PURE_PYTHON or _cPickleCache is None else _cPickleCache

Persistent = _persistence.Persistent
GHOST = _persistence.GHOST
UPTODATE = _persistence.UPTODATE
CHANGED = _persistence.CHANGED
STICKY = _persistence.STICKY
PickleCache = _picklecache.PickleCache

sys.modules['persistent.TimeStamp'] = sys.modules['persistent.timestamp']
github collective / collective.solr / src / collective / solr / exportimport.py View on Github external
def importSolrSettings(context):
    """ import settings for solr integration from an XML file """
    site = context.getSite()
    utility = queryUtility(ISolrConnectionConfig, context=site)
    if utility is None:
        logger = context.getLogger('collective.solr')
        logger.info('Nothing to import.')
        return
    if IPersistent.providedBy(utility):
        importObjects(utility, '', context)
github zopefoundation / Zope / src / OFS / interfaces.py View on Github external
error_type=None, error_value=None, tb=None,
                                   error_tb=None, error_message='',
                                   tagSearch=None, error_log_url=''):
        """Raise standard error message.
        """


# XXX: based on OFS.SimpleItem.Item_w__name__
class IItemWithName(IItem):

    """Item with name.
    """


# XXX: based on OFS.SimpleItem.SimpleItem
class ISimpleItem(IItem, IPersistent, IAcquirer, IRoleManager):

    """Not-so-simple item.
    """


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on OFS.CopySupport.CopyContainer
class ICopyContainer(Interface):

    """Interface for containerish objects which allow cut/copy/paste"""

    # The following three methods should be overridden to store sub-objects
    # as non-attributes.
    def _setOb(id, object):
        """
github zopefoundation / Zope / src / OFS / interfaces.py View on Github external
context.

        Passing a false value for the validate_src argument will skip
        checking the passed in object in its existing context. This is
        mainly useful for situations where the passed in object has no
        existing context, such as checking an object during an import
        (the object will not yet have been connected to the
        acquisition hierarchy).
        """


# XXX: might contain non-API methods and outdated comments;
#      not synced with ZopeBook API Reference;
#      based on OFS.ObjectManager.ObjectManager
class IObjectManager(IZopeObject, ICopyContainer, INavigation, IManageable,
                     IAcquirer, IPersistent, ITraversable,
                     IPossibleSite, IContainer):
    """Generic object manager

    This interface provides core behavior for collections of heterogeneous
    objects."""

    meta_types = Tuple(
        title=u"Meta types",
        description=u"Sub-object types that are specific to this object",
    )

    isAnObjectManager = Bool(
        title=u"Is an object manager",
    )

    manage_main = Attribute(""" """)