[Checkins] SVN: z3c.encryptedpersistent/ Initial package import
Randy Crafton
randycrafton at gmail.com
Tue Jun 24 17:07:18 EDT 2008
Log message for revision 87716:
Initial package import
Changed:
A z3c.encryptedpersistent/
A z3c.encryptedpersistent/trunk/
A z3c.encryptedpersistent/trunk/CHANGES.txt
A z3c.encryptedpersistent/trunk/README.txt
A z3c.encryptedpersistent/trunk/bootstrap.py
A z3c.encryptedpersistent/trunk/buildout.cfg
A z3c.encryptedpersistent/trunk/setup.py
A z3c.encryptedpersistent/trunk/src/
A z3c.encryptedpersistent/trunk/src/z3c/
A z3c.encryptedpersistent/trunk/src/z3c/__init__.py
A z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/
A z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/__init__.py
A z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/configure.zcml
A z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/encryptedpersistent.py
A z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/interfaces.py
-=-
Added: z3c.encryptedpersistent/trunk/CHANGES.txt
===================================================================
Added: z3c.encryptedpersistent/trunk/README.txt
===================================================================
Added: z3c.encryptedpersistent/trunk/bootstrap.py
===================================================================
--- z3c.encryptedpersistent/trunk/bootstrap.py (rev 0)
+++ z3c.encryptedpersistent/trunk/bootstrap.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2008 Zope Corporation 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.
+#
+##############################################################################
+"""Bootstrap a buildout-based project
+
+Simply run this script in a directory containing a buildout.cfg.
+The script accepts buildout command-line options, so you can
+use the -c option to specify an alternate configuration file.
+
+$Id:$
+"""
+
+import os, shutil, sys, tempfile, urllib2
+
+tmpeggs = tempfile.mkdtemp()
+
+ez = {}
+exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
+ ).read() in ez
+ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
+
+import pkg_resources
+
+cmd = 'from setuptools.command.easy_install import main; main()'
+if sys.platform == 'win32':
+ cmd = '"%s"' % cmd # work around spawn lamosity on windows
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
+ dict(os.environ,
+ PYTHONPATH=
+ ws.find(pkg_resources.Requirement.parse('setuptools')).location
+ ),
+ ) == 0
+
+ws.add_entry(tmpeggs)
+ws.require('zc.buildout')
+import zc.buildout.buildout
+zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
+shutil.rmtree(tmpeggs)
Property changes on: z3c.encryptedpersistent/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.encryptedpersistent/trunk/buildout.cfg
===================================================================
--- z3c.encryptedpersistent/trunk/buildout.cfg (rev 0)
+++ z3c.encryptedpersistent/trunk/buildout.cfg 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,27 @@
+[buildout]
+develop = .
+parts = test checker coverage-test coverage-report
+
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = z3c.encryptedpersistent [test]
+defaults = ['--tests-pattern', '^f?tests$', '-v']
+
+
+[checker]
+recipe = lovely.recipe:importchecker
+path = src/z3c/encryptedpersistent
+
+
+[coverage-test]
+recipe = zc.recipe.testrunner
+eggs = z3c.encryptedpersistent [test]
+defaults = ['--coverage', '../../coverage']
+
+
+[coverage-report]
+recipe = zc.recipe.egg
+eggs = z3c.coverage
+scripts = coverage=coverage-report
+arguments = ('coverage', 'coverage/report')
Added: z3c.encryptedpersistent/trunk/setup.py
===================================================================
--- z3c.encryptedpersistent/trunk/setup.py (rev 0)
+++ z3c.encryptedpersistent/trunk/setup.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,65 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+$Id:$
+"""
+
+import os
+from setuptools import setup, find_packages
+
+def read(*rnames):
+ return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
+
+setup (
+ name='z3c.encryptedpersistent',
+ version='0.0.1dev',
+ author = "Stephan Richter, Randy Crafton",
+ author_email = "zope3-dev at zope.org",
+ description = "",
+ long_description=(
+ read('README.txt')
+ + '\n\n' +
+ read('CHANGES.txt')
+ ),
+ license = "ZPL 2.1",
+ keywords = "zope3 encryption persistent zodb",
+ classifiers = [
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: Developers',
+ 'License :: OSI Approved :: Zope Public License',
+ 'Programming Language :: Python',
+ 'Natural Language :: English',
+ 'Operating System :: OS Independent',
+ 'Topic :: Internet :: WWW/HTTP',
+ 'Framework :: Zope3'],
+ url = 'http://cheeseshop.python.org/pypi/z3c.encryptedpersistent',
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['z3c'],
+ extras_require = dict(
+ test = [
+ 'zope.app.securitypolicy',
+ 'zope.app.testing',
+ 'zope.testing',
+ ],
+ ),
+ install_requires = [
+ 'setuptools',
+ 'zope.component',
+ 'zope.schema',
+ ],
+ zip_safe = False,
+)
Property changes on: z3c.encryptedpersistent/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.encryptedpersistent/trunk/src/z3c/__init__.py
===================================================================
--- z3c.encryptedpersistent/trunk/src/z3c/__init__.py (rev 0)
+++ z3c.encryptedpersistent/trunk/src/z3c/__init__.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,7 @@
+# this is a namespace package
+try:
+ import pkg_resources
+ pkg_resources.declare_namespace(__name__)
+except ImportError:
+ import pkgutil
+ __path__ = pkgutil.extend_path(__path__, __name__)
\ No newline at end of file
Property changes on: z3c.encryptedpersistent/trunk/src/z3c/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/__init__.py
===================================================================
--- z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/__init__.py (rev 0)
+++ z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/__init__.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,17 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+$Id:$
+"""
+
Property changes on: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/configure.zcml
===================================================================
--- z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/configure.zcml (rev 0)
+++ z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/configure.zcml 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,7 @@
+<configure
+ xmlns="http://namespaces.zope.org/zope"
+ i18n_domain="z3c">
+
+
+
+</configure>
\ No newline at end of file
Added: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/encryptedpersistent.py
===================================================================
--- z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/encryptedpersistent.py (rev 0)
+++ z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/encryptedpersistent.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import cPickle
+import persistent
+import zope.interface
+
+import interfaces
+
+class EncryptedPersistent(persistent.Persistent):
+ zope.interface.implements(interfaces.IEncryptedPersistent)
+
+ # See interfaces.IEncryptedPersistent
+ __key__ = None
+
+ def __getstate__(self):
+ # 1. Check that the key is really in the client.
+ encryption = zope.component.getUtility(interfaces.IEncryption)
+ if self.__key__ not in encryption:
+ raise interfaces.InvalidKey(self.__key__)
+ # 2. Get the state of the object using the Persistent implementation.
+ state = super(EncryptedPersistent, self).__getstate__()
+ # 3. Convert the state to a string.
+ stateStr = cPickle.dumps(state)
+ # 4. Encrypt the state string and return it as the state.
+ return (self.__key__, encryption[self.__key__].encrypt(stateStr))
+
+ def __setstate__(self, (key, encryptedState)):
+ # 1. Set the key on the object first:
+ self.__key__ = key
+ # 2. Decrypt the state string.
+ encryption = zope.component.getUtility(interfaces.IEncryption)
+ stateStr = encryption[self.__key__].decrypt(encryptedState)
+ # 3. Convert the state string to the state
+ state = cPickle.loads(stateStr)
+ # 4. Set the state of the object using the Persistent implementation.
+ super(EncryptedPersistent, self).__setstate__(state)
Property changes on: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/encryptedpersistent.py
___________________________________________________________________
Name: svn:keywords
+ Id
Added: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/interfaces.py
===================================================================
--- z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/interfaces.py (rev 0)
+++ z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/interfaces.py 2008-06-24 21:07:16 UTC (rev 87716)
@@ -0,0 +1,31 @@
+##############################################################################
+#
+# Copyright (c) 2008 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.
+#
+##############################################################################
+"""
+$Id:$
+"""
+__docformat__ = "reStructuredText"
+
+import zope.interface
+import zope.schema
+
+
+class IEncryption(zope.interface.Interface):
+ """Utility providing encryption mechanism"""
+
+ def encrypt(data):
+ """Returns the encrypted data"""
+
+ def decrypt(data):
+ """Returns the decrypted data"""
+
Property changes on: z3c.encryptedpersistent/trunk/src/z3c/encryptedpersistent/interfaces.py
___________________________________________________________________
Name: svn:keywords
+ Id
More information about the Checkins
mailing list