1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (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
#
##############################################################################
"""Prefer C implementations of Persistent / PickleCache / TimeStamp.
Fall back to pure Python implementations.
"""
import os
PURE_PYTHON = os.environ.get('PURE_PYTHON')
if not PURE_PYTHON:
try:
from persistent.cPersistence import Persistent
from persistent.cPersistence import GHOST
from persistent.cPersistence import UPTODATE
from persistent.cPersistence import CHANGED
from persistent.cPersistence import STICKY
from persistent.cPersistence import simple_new
except ImportError: #pragma NO COVER
from persistent.persistence import Persistent
from persistent.persistence import GHOST
from persistent.persistence import UPTODATE
from persistent.persistence import CHANGED
from persistent.persistence import STICKY
else:
from persistent._compat import copy_reg
copy_reg.constructor(simple_new)
# Make an interface declaration for Persistent, if zope.interface
# is available. Note that the Python version already does this.
try:
from zope.interface import classImplements
except ImportError: #pragma NO COVER
pass
else:
from persistent.interfaces import IPersistent
classImplements(Persistent, IPersistent)
try:
from persistent.cPickleCache import PickleCache
except ImportError: #pragma NO COVER
from persistent.picklecache import PickleCache
try:
import persistent.TimeStamp
except ImportError: #pragma NO COVER
import persistent.timestamp as TimeStamp
import sys
sys.modules['persistent.TimeStamp'
] = sys.modules['persistent.timestamp']
else: #pragma NO COVER
from persistent.persistence import Persistent
from persistent.persistence import GHOST
from persistent.persistence import UPTODATE
from persistent.persistence import CHANGED
from persistent.persistence import STICKY
from persistent.picklecache import PickleCache
import persistent.timestamp as TimeStamp
import sys
sys.modules['persistent.TimeStamp'] = sys.modules['persistent.timestamp']
|