Skip to content

Instantly share code, notes, and snippets.

@jvanasco
jvanasco / pyramid_mailer.repsonse.py.diff
Last active December 16, 2015 20:29
another diff for pyramid_mailer's response. this one is a bit better.
diff --git a/pyramid_mailer/response.py b/pyramid_mailer/response.py
index 603e3d8..831fc8a 100644
--- a/pyramid_mailer/response.py
+++ b/pyramid_mailer/response.py
@@ -38,6 +38,7 @@ import quopri
import sys
import mimetypes
import string
+import types
from email.mime.base import MIMEBase
@jvanasco
jvanasco / nginx.conf
Last active December 17, 2015 16:19
config
server {
listen 80;
server_name
graphite.example.com
;
error_log /var/log/uwsgi/graphite_a-nginx.log
location / {
auth_basic "Graphite";
@jvanasco
jvanasco / __init__.py
Created May 24, 2013 04:20
using statsd to profile a pyramid app
config.add_subscriber(\
"app.subscribers.statsd_timing",
"pyramid.events.ContextFound")
@jvanasco
jvanasco / 0001-TEST.py
Created June 14, 2013 16:41
Pyramid Bootstrap Idea
from _api import IntegratedApi
api = IntegratedApi()
api.bootstrapped.request.dbSession.writer.rollback()
## do stuff
api.request_finish()
api.request_new()
## do stuff
@jvanasco
jvanasco / extract_kvs.py
Last active December 18, 2015 12:39
extract k/v pairs from text [python]
import re
RE_kwargs_unified = re.compile("""
(?P<arg>
(?P<k>[\w\-]+)
=
(?P<q>"|')
(?P<v>[^"]+)
(?P=q)
)+
def includeme(config):
config.add_tween( 'exception_logging_tween_factory' , under=EXCVIEW )
def exception_logging_tween_factory(handler,registry):
def exception_logging_tween(request):
ignored = (WSGIHTTPException,)
try:
return handler(request)
except ignored:
raise
@jvanasco
jvanasco / custom_sessions.py
Last active December 18, 2015 18:39
configurable sessions with pyramid
import logging
log = logging.getLogger(__name__)
import pyramid_beaker
from pyramid.session import UnencryptedCookieSessionFactoryConfig
import types
valid_args_pyramid_UnencryptedCookieSessionFactoryConfig = [
'secret',
from pyramid.config import Configurator
from pyramid.view import view_config
import pyramid_mailer
from pyramid_mailer import get_mailer
from pyramid_mailer.message import Message as MailerMessage
from pyramid_mailer import mailer_factory_from_settings
def main(global_config, **settings):
@jvanasco
jvanasco / whisper.py
Last active December 21, 2015 02:08
diff against current graphite/carbon/whisper release (0.9.10) to ensure intermediate directories exist in the whisper database ( otherwise, stuff fails )
--- whisper.py 2013-08-14 11:59:04.000000000 -0400
+++ whisper.py.fix 2013-08-14 11:59:17.000000000 -0400
@@ -324,11 +324,6 @@
if os.path.exists(path):
raise InvalidConfiguration("File %s already exists!" % path)
+ # ensure the path
+ _path_dir = os.path.split(path)
+ if not os.path.exists( _path_dir ):
+ os.makedirs( _path_dir )