Porting an application across platforms is never particularly easy, nor very interesting. In fact, it's usually a terrible idea: in general, if it ain't broke, don't fix it. But sometimes you have to do it. Maybe a new platform has a feature you believe you can't live without, or the project scope is expanding in directions that make you feel like your original platform choice might not have been the best, or maybe it's just necessary to port for political reasons. Whatever.
[chrism@thinko ~]$ ab -n1001 http://127.0.0.1:8080/hello/fred | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking 127.0.0.1 (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from chameleon import PageTemplate | |
template = PageTemplate("Hello, ${name}.") | |
for name in ('Fred', u'ἃc', '\xf8'): | |
print(template(name=name)) |
Porting an application across platforms is never particularly easy, nor very interesting. In fact, it's usually a terrible idea: in general, if it ain't broke, don't fix it. But sometimes you have to do it. Maybe a new platform has a feature you believe you can't live without, or the project scope is expanding in directions that make you feel like your original platform choice might not have been the best, or maybe it's just necessary to port for political reasons. Whatever.
>>> import pytz | |
>>> eastern = pytz.timezone('US/Eastern') | |
>>> import datetime | |
>>> now = datetime.datetime.now().replace(tzinfo=eastern) | |
>>> now.strftime('%a, %d %b %Y %H:%M:%S %z') | |
'Mon, 16 Jun 2014 15:01:02 -0456' | |
456. 456. What the fuck. |
[chrism@thinko env27]$ bin/pcreate -s substanced mything | |
Creating directory /home/chrism/projects/substanced/env27/mything | |
Recursing into +package+ | |
Creating /home/chrism/projects/substanced/env27/mything/mything/ | |
Copying __init__.py_tmpl to /home/chrism/projects/substanced/env27/mything/mything/__init__.py | |
Copying resources.py to /home/chrism/projects/substanced/env27/mything/mything/resources.py | |
Recursing into retail | |
Creating /home/chrism/projects/substanced/env27/mything/mything/retail/ | |
Copying __init__.py_tmpl to /home/chrism/projects/substanced/env27/mything/mything/retail/__init__.py | |
Recursing into templates |
[chrism@thinko temp]$ git clone [email protected]:Pylons/substanced.git | |
Cloning into 'substanced'... | |
remote: Counting objects: 18768, done. | |
remote: Total 18768 (delta 0), reused 0 (delta 0) | |
Receiving objects: 100% (18768/18768), 10.79 MiB | 3.60 MiB/s, done. | |
Resolving deltas: 100% (9778/9778), done. | |
[chrism@thinko temp]$ virtualenv -ppython2.7 env27 | |
Running virtualenv with interpreter /home/chrism/bin/python2.7 | |
New python executable in env27/bin/python2.7 | |
Also creating executable in env27/bin/python |
# views.py | |
from pyramid.view import view_config | |
@view_config(route_name='home', renderer='templates/mytemplate.pt') | |
def my_view(request): | |
url = request.route_url('foo') | |
return {'project': 'myproj', 'url':url} |
Porting an application across platforms is never particularly easy, nor very interesting. In fact, it's usually a terrible idea: in general, if it ain't broke, don't fix it. But sometimes you have to do it. Maybe a new platform has a feature you believe you can't live without, or the project scope is expanding in directions that make you feel like your original platform choice might not have been the best, or maybe it's just necessary to port for political reasons. Whatever.
from wsgiref.simple_server import make_server | |
from zope.interface import ( | |
Interface, | |
alsoProvides, | |
) | |
from pyramid.config import Configurator | |
from pyramid.httpexceptions import HTTPFound | |
from pyramid.response import Response |