[Checkins] SVN: zopyx.smartprintng.server/trunk/ merged bfg branch
Andreas Jung
andreas at andreas-jung.com
Mon Jul 6 15:22:49 EDT 2009
Log message for revision 101672:
merged bfg branch
Changed:
U zopyx.smartprintng.server/trunk/docs/HISTORY.txt
A zopyx.smartprintng.server/trunk/server.ini
U zopyx.smartprintng.server/trunk/setup.py
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/configure.zcml
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/logger.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/models.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/run.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/templates/
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/tests.py
D zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py
A zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py
-=-
Modified: zopyx.smartprintng.server/trunk/docs/HISTORY.txt
===================================================================
--- zopyx.smartprintng.server/trunk/docs/HISTORY.txt 2009-07-06 19:12:15 UTC (rev 101671)
+++ zopyx.smartprintng.server/trunk/docs/HISTORY.txt 2009-07-06 19:22:49 UTC (rev 101672)
@@ -1,6 +1,11 @@
Changelog
=========
+0.3.0 (2009/07/06)
+------------------
+
+* switched to repoze.bfg
+
0.2.0 (2009/07/06)
------------------
Copied: zopyx.smartprintng.server/trunk/server.ini (from rev 101660, zopyx.smartprintng.server/branches/bfg/server.ini)
===================================================================
--- zopyx.smartprintng.server/trunk/server.ini (rev 0)
+++ zopyx.smartprintng.server/trunk/server.ini 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,13 @@
+[DEFAULT]
+debug = true
+
+[app:main]
+use = egg:zopyx.smartprintng.server#app
+reload_templates = true
+debug_authorization = false
+debug_notfound = false
+
+[server:main]
+use = egg:Paste#http
+host = 0.0.0.0
+port = 6543
Modified: zopyx.smartprintng.server/trunk/setup.py
===================================================================
--- zopyx.smartprintng.server/trunk/setup.py 2009-07-06 19:12:15 UTC (rev 101671)
+++ zopyx.smartprintng.server/trunk/setup.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os
-version = '0.2.0'
+version = '0.3.0'
setup(name='zopyx.smartprintng.server',
version=version,
@@ -24,12 +24,13 @@
zip_safe=False,
install_requires=[
'setuptools',
- 'twisted',
+ 'repoze.bfg',
'uuid',
'zopyx.convert2',
# -*- Extra requirements: -*-
],
- entry_points=dict(
- console_scripts=['smartprintng_server_twisted=zopyx.smartprintng.server.twisted_srv:main']
+ entry_points="""\
+ [paste.app_factory]
+ app = zopyx.smartprintng.server.run:app
+ """
)
- )
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py 2009-07-06 19:12:15 UTC (rev 101671)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/__init__.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -1,4 +1,2 @@
-##########################################################################
-# zopyx.smartprintng.server
-# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
-##########################################################################
+# A package
+
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py 2009-07-06 19:12:15 UTC (rev 101671)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/client_demo/zip_client.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -4,11 +4,11 @@
import tempfile
# XMLRPC server instance
-server = xmlrpclib.Server('http://localhost:7080/')
+server = xmlrpclib.ServerProxy('http://localhost:6543/convertZIP')
# send the ZIP archive base64 encoded
-zip_data = server.convertZIP(base64.encodestring(file('test.zip', 'rb').read()),
- 'pdf-prince')
+zip_data = server(base64.encodestring(file('test.zip', 'rb').read())[:-10],
+ 'pdf-prince')
# and receive the result PDF as base64 encoded ZIP archive
zip_temp = tempfile.mktemp()
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/configure.zcml (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/configure.zcml)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/configure.zcml (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/configure.zcml 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,23 @@
+<configure xmlns="http://namespaces.repoze.org/bfg">
+
+ <!-- this must be included for the view declarations to work -->
+ <include package="repoze.bfg.includes" />
+
+ <view
+ for=".models.Server"
+ view=".views.index"
+ />
+
+ <view
+ for=".models.Server"
+ view=".views.convertZIP"
+ name="convertZIP"
+ />
+
+ <view
+ for=".models.Server"
+ view=".views.static_view"
+ name="static"
+ />
+
+</configure>
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/logger.py (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/logger.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/logger.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/logger.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,6 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
+from zopyx.convert2.logger import LOG
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/models.py (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/models.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/models.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/models.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,7 @@
+class Server(object):
+ pass
+
+root = Server()
+
+def get_root(environ):
+ return root
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/run.py (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/run.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/run.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/run.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,11 @@
+from repoze.bfg.router import make_app
+
+def app(global_config, **kw):
+ """ This function returns a repoze.bfg.router.Router object. It
+ is usually called by the PasteDeploy framework during ``paster
+ serve``"""
+ # paster app config callback
+ from zopyx.smartprintng.server.models import get_root
+ import zopyx.smartprintng.server
+ return make_app(get_root, zopyx.smartprintng.server, options=kw)
+
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/tests.py (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/tests.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/tests.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/tests.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,73 @@
+import unittest
+
+from repoze.bfg import testing
+
+class ViewTests(unittest.TestCase):
+
+ """ These tests are unit tests for the view. They test the
+ functionality of *only* the view. They register and use dummy
+ implementations of repoze.bfg functionality to allow you to avoid
+ testing 'too much'"""
+
+ def setUp(self):
+ """ cleanUp() is required to clear out the application registry
+ between tests (done in setUp for good measure too)
+ """
+ testing.cleanUp()
+
+ def tearDown(self):
+ """ cleanUp() is required to clear out the application registry
+ between tests
+ """
+ testing.cleanUp()
+
+ def test_my_view(self):
+ from my_server.views import my_view
+ context = testing.DummyModel()
+ request = testing.DummyRequest()
+ renderer = testing.registerDummyRenderer('templates/mytemplate.pt')
+ response = my_view(context, request)
+ renderer.assert_(project='my_server')
+
+class ViewIntegrationTests(unittest.TestCase):
+ """ These tests are integration tests for the view. These test
+ the functionality the view *and* its integration with the rest of
+ the repoze.bfg framework. They cause the entire environment to be
+ set up and torn down as if your application was running 'for
+ real'. This is a heavy-hammer way of making sure that your tests
+ have enough context to run properly, and it tests your view's
+ integration with the rest of BFG. You should not use this style
+ of test to perform 'true' unit testing as tests will run faster
+ and will be easier to write if you use the testing facilities
+ provided by bfg and only the registrations you need, as in the
+ above ViewTests.
+ """
+ def setUp(self):
+ """ This sets up the application registry with the
+ registrations your application declares in its configure.zcml
+ (including dependent registrations for repoze.bfg itself).
+ """
+ testing.cleanUp()
+ import my_server
+ import zope.configuration.xmlconfig
+ zope.configuration.xmlconfig.file('configure.zcml',
+ package=my_server)
+
+ def tearDown(self):
+ """ Clear out the application registry """
+ testing.cleanUp()
+
+ def test_my_view(self):
+ from my_server.views import my_view
+ context = testing.DummyModel()
+ request = testing.DummyRequest()
+ result = my_view(context, request)
+ self.assertEqual(result.status, '200 OK')
+ body = result.app_iter[0]
+ self.failUnless('Welcome to' in body)
+ self.assertEqual(len(result.headerlist), 2)
+ self.assertEqual(result.headerlist[0],
+ ('Content-Type', 'text/html; charset=UTF-8'))
+ self.assertEqual(result.headerlist[1], ('Content-Length',
+ str(len(body))))
+
Deleted: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py 2009-07-06 19:12:15 UTC (rev 101671)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/twisted_srv.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -1,38 +0,0 @@
-##########################################################################
-# zopyx.smartprintng.server
-# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
-##########################################################################
-
-from twisted.web import xmlrpc, server
-from base import ServerCore
-from logger import LOG
-
-class Server(xmlrpc.XMLRPC, ServerCore):
- """ SmartPrintNG Server (based on Twisted)"""
-
- def xmlrpc_convertZIP(self, zip_archive, converter_name='pdf-prince'):
- """ Process html-file + images within a ZIP archive """
-
- try:
- return self.convertZIP(zip_archive, converter_name)
- except Exception, e:
- msg = 'Conversion failed (%s)' % e
- LOG.error(msg, exc_info=True)
- return xmlrpc.Fault(123, msg)
-
-def main():
- from twisted.internet import reactor
- from optparse import OptionParser
-
- parser = OptionParser()
- parser.add_option("-p", "--port", dest="port", type="int",
- help="port", default=7080)
-
- (options, args) = parser.parse_args()
- LOG.debug('Started SmartPrintNG XMLRPC server(port %d)' % options.port)
- r = Server()
- reactor.listenTCP(options.port, server.Site(r))
- reactor.run()
-
-if __name__ == '__main__':
- main()
Copied: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py (from rev 101660, zopyx.smartprintng.server/branches/bfg/zopyx/smartprintng/server/views.py)
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py (rev 0)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py 2009-07-06 19:22:49 UTC (rev 101672)
@@ -0,0 +1,31 @@
+##########################################################################
+# zopyx.smartprintng.server
+# (C) 2008, 2009, ZOPYX Ltd & Co. KG, Tuebingen, Germany
+##########################################################################
+
+
+from repoze.bfg.chameleon_zpt import render_template_to_response
+from repoze.bfg.view import static
+from logger import LOG
+
+static_view = static('templates/static')
+
+def index(context, request):
+ return render_template_to_response('templates/index.pt',
+ request = request,
+ project = 'zopyx.smartprintng.server')
+
+from repoze.bfg.xmlrpc import xmlrpc_view
+import xmlrpclib
+
+ at xmlrpc_view
+def convertZIP(context, zip_archive, converter_name='pdf-prince'):
+ from zopyx.smartprintng.server.base import ServerCore
+ core = ServerCore()
+ try:
+ return core.convertZIP(zip_archive, converter_name)
+ except Exception, e:
+ msg = 'Conversion failed (%s)' % e
+ LOG.error(msg, exc_info=True)
+ return xmlrpclib.Fault(123, msg)
+
More information about the Checkins
mailing list