[Checkins] SVN: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/ added a simple selftest
Andreas Jung
andreas at andreas-jung.com
Sun Sep 20 08:36:29 EDT 2009
Log message for revision 104373:
added a simple selftest
Changed:
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/templates/index.pt
U zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py
-=-
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/templates/index.pt
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/templates/index.pt 2009-09-20 07:52:30 UTC (rev 104372)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/templates/index.pt 2009-09-20 12:36:28 UTC (rev 104373)
@@ -22,6 +22,13 @@
<span class="label">Available converters:</span>
<span tal:content="python: ', '.join(converters)" />
</div>
+ <div>
+ <span class="label">Self-test:</span>
+ <tal:loop repeat ="c converters">
+ <a href="selftest?converter=$c">$c</a>
+ </tal:loop>
+ </div>
+
<div id="footer">
(C) 2009, ZOPYX Ltd. & Co. KG, <a href="http://www.zopyx.com">www.zopyx.com</a>, <a href="mailto:info at zopyx.com">info at zopyx.com</a>
</div>
Modified: zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py
===================================================================
--- zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py 2009-09-20 07:52:30 UTC (rev 104372)
+++ zopyx.smartprintng.server/trunk/zopyx/smartprintng/server/views.py 2009-09-20 12:36:28 UTC (rev 104373)
@@ -51,7 +51,31 @@
version=version,
project='zopyx.smartprintng.server')
+ at bfg_view(for_=Server, request_type='GET', permission='read', name='selftest')
+class selftest(object):
+ """ Server selftest """
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
+
+ def __call__(self, converter=None):
+ converter = self.request.params['converter']
+ test_file = os.path.join(os.path.dirname(__file__), 'test_data', 'test.html')
+ result = self.context._convert(test_file, converter)
+ if result['status'] == 0:
+ output_filename = result['output_filename']
+ ct, dummy = mimetypes.guess_type(output_filename)
+ basename, ext = os.path.splitext(output_filename)
+ headers = [('content-disposition','attachment; filename=selftest-%s%s' % (converter,ext)),
+ ('content-type', ct)]
+ return Response(body=file(output_filename, 'rb').read(),
+ content_type=ct,
+ headerlist=headers
+ )
+ raise RuntimeError
+
+
@bfg_view(for_=Server, name='deliver')
def deliver(context, request):
""" Send out a generated output file """
More information about the checkins
mailing list