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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- day 1 -- | |
The Cynical Introduction | |
All Code Is Terrible | |
Avoid Shame, Test Everything | |
Proving It Works Isn't The Goal | |
But It Makes Me So Slow!? | |
Don't Be Afraid to Throw It Away |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sameroute.py | |
from wsgiref.simple_server import make_server | |
from pyramid.config import Configurator | |
from pyramid.response import Response | |
def hello_world(request): | |
return Response('Hello %(name)s!' % request.matchdict) | |
if __name__ == '__main__': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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. |
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.