[Checkins] SVN: zc.ssl/ Initial import of zc.ssl.
Albertas Agejevas
alga at pov.lt
Wed Nov 14 08:19:42 EST 2007
Log message for revision 81831:
Initial import of zc.ssl.
Changed:
A zc.ssl/
A zc.ssl/trunk/
A zc.ssl/trunk/bootstrap.py
A zc.ssl/trunk/buildout.cfg
A zc.ssl/trunk/setup.py
A zc.ssl/trunk/src/
A zc.ssl/trunk/src/zc/
A zc.ssl/trunk/src/zc/__init__.py
A zc.ssl/trunk/src/zc/ssl/
A zc.ssl/trunk/src/zc/ssl/__init__.py
A zc.ssl/trunk/src/zc/ssl/tests.py
A zc.ssl/trunk/src/zc/ssl/tests.txt
-=-
Added: zc.ssl/trunk/bootstrap.py
===================================================================
--- zc.ssl/trunk/bootstrap.py (rev 0)
+++ zc.ssl/trunk/bootstrap.py 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,48 @@
+##############################################################################
+#
+# Copyright (c) 2006 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
+
+ws = pkg_resources.working_set
+assert os.spawnle(
+ os.P_WAIT, sys.executable, sys.executable,
+ '-c', 'from setuptools.command.easy_install import main; main()',
+ '-mqNxd', tmpeggs, 'zc.buildout',
+ {'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: zc.ssl/trunk/bootstrap.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.ssl/trunk/buildout.cfg
===================================================================
--- zc.ssl/trunk/buildout.cfg (rev 0)
+++ zc.ssl/trunk/buildout.cfg 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,12 @@
+[buildout]
+develop = .
+parts = test mypython
+
+[mypython]
+recipe = zc.recipe.egg
+interpreter = python
+eggs = zc.ssl
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = zc.ssl
Property changes on: zc.ssl/trunk/buildout.cfg
___________________________________________________________________
Name: svn:keywords
+ Id
Added: zc.ssl/trunk/setup.py
===================================================================
--- zc.ssl/trunk/setup.py (rev 0)
+++ zc.ssl/trunk/setup.py 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,22 @@
+from setuptools import setup, find_packages
+
+setup(
+ name = "zc.ssl",
+ version = "1.0",
+ author = "Zope Corporation",
+ author_email = "zope3-dev#zope.org",
+ description = "An HTTPSConnection implementation with the new ssl module",
+ keywords = "ssl https",
+
+ packages = find_packages('src'),
+ include_package_data = True,
+ package_dir = {'':'src'},
+ namespace_packages = ['zc'],
+ install_requires = [
+ 'zope.testing',
+ 'setuptools',
+ 'ssl-for-setuptools',
+ ],
+ dependency_links = ['http://download.zope.org/distribution/'],
+ license = "ZPL 2.1",
+ )
Property changes on: zc.ssl/trunk/setup.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.ssl/trunk/src/zc/__init__.py
===================================================================
--- zc.ssl/trunk/src/zc/__init__.py (rev 0)
+++ zc.ssl/trunk/src/zc/__init__.py 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,5 @@
+try:
+ __import__('pkg_resources').declare_namespace(__name__)
+except:
+ # bootstrapping
+ pass
Property changes on: zc.ssl/trunk/src/zc/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.ssl/trunk/src/zc/ssl/__init__.py
===================================================================
--- zc.ssl/trunk/src/zc/ssl/__init__.py (rev 0)
+++ zc.ssl/trunk/src/zc/ssl/__init__.py 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,36 @@
+"""An HTTPS connection implementation that does not:
+
+ * depend on swig
+ * ignore server certificates
+
+$Id$
+"""
+import socket
+import httplib
+import ssl
+import os.path
+
+
+class HTTPSConnection(httplib.HTTPSConnection):
+ """An HTTPS connection using the ssl module"""
+
+ def __init__(self, host, port=None, key_file=None, cert_file=None,
+ strict=None, timeout=None):
+ # timeout is None or float
+ self.timeout = timeout
+ httplib.HTTPSConnection.__init__(self, host, port, key_file, cert_file,
+ strict)
+ if self.cert_file is None:
+ self.cert_file = os.path.join(os.path.dirname(__file__),
+ "certs.pem")
+
+ ssl_wrap_socket = staticmethod(ssl.wrap_socket)
+
+ def connect(self):
+ "Connect to a host on a given (SSL) port."
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ self.sock = self.ssl_wrap_socket(sock,
+ ca_certs=self.cert_file,
+ cert_reqs=ssl.CERT_REQUIRED)
+ self.sock.settimeout(self.timeout)
+ self.sock.connect((self.host, self.port))
Property changes on: zc.ssl/trunk/src/zc/ssl/__init__.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.ssl/trunk/src/zc/ssl/tests.py
===================================================================
--- zc.ssl/trunk/src/zc/ssl/tests.py (rev 0)
+++ zc.ssl/trunk/src/zc/ssl/tests.py 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,31 @@
+"""Tests for zc.ssl
+
+$Id$
+"""
+import unittest
+import zope.testing.doctest
+
+
+class StubSSLWrapper(object):
+
+ def __init__(self, sock, ca_certs=None, cert_reqs=None):
+ self.sock = sock
+ self.ca_certs = ca_certs
+ self.cert_reqs = cert_reqs
+ print "sssl(%r, %r, %r)" % (sock, ca_certs, cert_reqs)
+
+ def settimeout(self, timeout):
+ print "sssl.settimeout(%r)" % timeout
+
+ def connect(self, hostport):
+ print "sssl.connect(%r)" % (hostport, )
+
+
+def test_suite():
+ suite = unittest.TestSuite([
+ zope.testing.doctest.DocFileSuite(
+ 'tests.txt',
+ optionflags=zope.testing.doctest.ELLIPSIS),
+ ])
+
+ return suite
Property changes on: zc.ssl/trunk/src/zc/ssl/tests.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: zc.ssl/trunk/src/zc/ssl/tests.txt
===================================================================
--- zc.ssl/trunk/src/zc/ssl/tests.txt (rev 0)
+++ zc.ssl/trunk/src/zc/ssl/tests.txt 2007-11-14 13:19:41 UTC (rev 81831)
@@ -0,0 +1,17 @@
+==============================
+Unit tests for HTTPSConnection
+==============================
+
+ >>> import zc.ssl.tests
+ >>> import zc.ssl
+ >>> sssl = zc.ssl.HTTPSConnection(
+ ... "creditcard.company", 443, None, "/etc/certs.pem", None, 3.14)
+ >>> sssl.ssl_wrap_socket = zc.ssl.tests.StubSSLWrapper
+
+The connect method sets the socket's timeout and invokes its
+connect method:
+
+ >>> sssl.connect()
+ sssl(<socket._socketobject object at ...>, '/etc/certs.pem', 2)
+ sssl.settimeout(3.1400000000000001)
+ sssl.connect(('creditcard.company', 443))
Property changes on: zc.ssl/trunk/src/zc/ssl/tests.txt
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
More information about the Checkins
mailing list