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
# myapp/subscribers.py | |
from myapp import helpers as h | |
from pyramid.events import subscriber | |
from pyramid.events import BeforeRender | |
def add_globals(event): | |
event['h'] = h | |
# myapp/__init__.py |
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
def commit_veto(environ, status, headers): | |
for good in ('10', '20', '30', '40'): | |
if not status.startswith(good): | |
return True | |
for header_name, header_value in headers: | |
if header_name.lower() == 'x-tm-abort': | |
return True |
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 inspect | |
import xmlrpclib | |
from zope.interface import implements | |
from zope.interface import providedBy | |
from pyramid.interfaces import IViewClassifier | |
from pyramid.interfaces import IView | |
from pyramid.interfaces import IViewMapperFactory |
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
# with pyramid tweak (and 80-column wrapping) | |
import time | |
import sys | |
import StringIO | |
class Bench(object): | |
def __init__(self, flags=None): | |
''' Flags: | |
* cgi: Build a new app every time. |
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 ~]$ curl -i -X POST http://127.0.0.1:8080/login | |
# HTTP/1.0 200 OK | |
# Server: PasteWSGIServer/0.5 Python/2.6.5 | |
# Date: Wed, 26 Jan 2011 18:18:22 GMT | |
# Content-Length: 4 | |
# Content-Type: text/plain; charset=UTF-8 | |
# POST[chrism@thinko curl -i http://127.0.0.1:8080/login | |
# HTTP/1.0 200 OK | |
# Server: PasteWSGIServer/0.5 Python/2.6.5 |
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 paste.httpserver import serve | |
from pyramid.view import view_config | |
from pyramid.response import Response | |
@view_config(route_name='login', request_method='GET') | |
@view_config(context='pyramid.exceptions.Forbidden') | |
def login(request): | |
return Response('Log In', status=401) |
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 transaction | |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy.exc import IntegrityError | |
from sqlalchemy.orm.session import object_session | |
from sqlalchemy import Integer | |
from sqlalchemy import Unicode | |
from sqlalchemy import Column |
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 shootout]$ env26/bin/python setup.py test -q | |
running test | |
running egg_info | |
writing requirements to shootout.egg-info/requires.txt | |
writing shootout.egg-info/PKG-INFO | |
writing top-level names to shootout.egg-info/top_level.txt | |
writing dependency_links to shootout.egg-info/dependency_links.txt | |
writing entry points to shootout.egg-info/entry_points.txt | |
writing paster_plugins to shootout.egg-info/paster_plugins.txt | |
reading manifest file 'shootout.egg-info/SOURCES.txt' |
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 JayD3e]$ git diff | |
diff --git a/jayd3e/tests/test_handlers.py b/jayd3e/tests/test_handlers.py | |
index d540562..0ab58e2 100644 | |
--- a/jayd3e/tests/test_handlers.py | |
+++ b/jayd3e/tests/test_handlers.py | |
@@ -5,10 +5,10 @@ from jayd3e.handlers.auth import AuthHandler | |
class TestHandlers(unittest.TestCase): | |
def setUp(self): | |
+ self.config = testing.setUp() |
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
# framework | |
from pyramid.view import view_config | |
from pyramid.interfaces import IRoutesMapper | |
class api(view_config): | |
def __init__(self, **kw): | |
view_config.__init__(self, **kw) | |
def __call__(self, func): |
OlderNewer