Skip to content

Instantly share code, notes, and snippets.

Use Pyramid

Install

If you don't have the latest and greatest Python install it from Python.org

In a terminal:

chord(
list(index_all_cases(index_name, cluster)) +\
list(index_all_patents(index_name, cluster)) +\
list(index_all_law_firms(index_name, cluster)) +\
list(index_all_attorneys(index_name, cluster)) +\
list(index_all_cpcs(index_name, cluster)),
)(switch_to_running_index_settings.s(index_name=index_name, cluster=cluster) |\
cleanup_old_indexes.s(by_date=True, prefix=prefix, cluster=cluster))

Keybase proof

I hereby claim:

  • I am gcarothers on github.
  • I am gavincarothers (https://keybase.io/gavincarothers) on keybase.
  • I have a public key whose fingerprint is 4EF1 6144 8024 2855 C8E4 F4F8 BFD9 CBF6 4483 588E

To claim this, I am signing this object:

2015-04-10

  • Pyramid Booth
  • What can programmers learn from pilots?
  • Hyperactive: HTTP/2 and Python
  • Lunch
  • Pyramid Booth
  • My Python's a little Rust-y
  • Stop Sucking Me Into Your Drama: A Personal Appeal For Loose Coupling
  • Break
  • Fire your supervisord: running Python apps on CoreOS
def engine_from_environ(prefix, settings, application_name=None):
"""Setup an SQLAlchemy engine with overrides from environment.
Maps KEYS_LIKE_THIS to keys.like.this"""
env_prefix = prefix.replace('.', '_').upper()
for env in os.environ:
if env.startswith(env_prefix):
key = env.replace('_', '.').lower()
settings[key] = os.environ[env]
if application_name is not None:
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__':
config = Configurator()
config.add_route('hello', '/hello/{name}')
home / sameroute.views.my_view *
home_again / <unknown> *
@view_config(context=Exception)
def exception_view(context, request):
# Check to see if debug toolbar is enabled.
from pyramid.interfaces import ITweens
tweens = request.registry.queryUtility(ITweens)
if tweens:
tween_list = tweens.explicit or tweens.implicit()
tween_names = zip(*tween_list)[0]
if tween_list and 'pyramid_debugtoolbar.toolbar_tween_factory' in\
tween_names:
pip install --upgrade 'pip>=1.4.1'
Requirement already up-to-date: pip>=1.4.1 in /home/lex/lib/python2.7/site-packages
pip install --upgrade 'setuptools>=0.8'
Requirement already up-to-date: setuptools>=0.8 in /home/lex/lib/python2.7/site-packages
pip install wheel
Requirement already satisfied (use --upgrade to upgrade): wheel in /home/lex/lib/python2.7/site-packages
pip wheel -w wheelhouse -f wheelhouse -r requirements.txt
ERROR: 'pip wheel' requires setuptools >= 0.8 for dist-info support. To fix this, run: pip install --upgrade setuptools
def forbid_user_messages(request, user):
"""Provide messaging to users who have an active session and become
disabled for some reason."""
if user.inactive and not request.is_xhr:
# Log out inactive users.
headers = forget(request)
if user.trial_expiration:
error_msg = """Your Lex Machina trial has expired.
Please <a href="mailto:sales@lexmachina.com">contact sales</a>
to subscribe."""