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 unicodedata | |
accented= { | |
'czech' : u'ťúůýžšřóňíěéďčá', | |
'french' : u"ùûüÿàâæçéèêëïîôœ", | |
'finnish' : u'äåö', | |
'danish' : u'åæéø', | |
'german' : u'äöüß', | |
'hungarian': u'áéíöóőüúű', | |
'icelandic': u'áæðéíóöþúý', |
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
class Error(Exception): | |
"""Base class for exceptions in this module.""" | |
def __init__(self, value=''): | |
self.value = value | |
def __str__(self): | |
return repr(self.value) | |
class HereIAm(Error): |
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 logging | |
log = logging.getLogger(__name__) | |
from pyramid.httpexceptions import HTTPFound | |
from pyramid.renderers import render_to_response | |
from pyramid.view import view_config | |
# all that's necessary to know is that _base sets self.request | |
from ..lib import handlers as _base |
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 main(global_config, **settings): | |
... | |
... | |
... | |
import pyramid | |
from pyramid_beaker import BeakerSessionFactoryConfig | |
from beaker.util import coerce_session_params | |
from pyramid.interfaces import ISessionFactory | |
from pyramid.decorator import reify |
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
# google services | |
# heavy js + tracking | |
google-analytics.com | |
googleadservices.com | |
doubleclick.net | |
gstatic.com | |
plusone.google.com | |
# social services | |
# heavy js + tracking |
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 pyramid.config import Configurator | |
from pyramid.response import Response | |
from pyramid.httpexceptions import HTTPFound | |
urls_debug = ('/raise','/return') | |
def _parse_cookies(items): | |
return [ (k,v) for (k,v) in items.iteritems() if k.lower() == 'set-cookie'] |
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 f(a,L=[]): | |
L.append(a) | |
return L | |
for i in range(0,3): | |
print f(i) | |
for i in range(3,6): | |
print f(i) |
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 recurse(number): | |
as_int = int(number) | |
if as_int >= 10 : | |
as_string = str(number) | |
value = sum(int(i) for i in as_string) | |
as_int = recurse( value ) | |
return as_int | |
print recurse(2012) |
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
class SettingsSection(Settings): | |
def __init__(self, settings=None, section_prefix=None, **kw): | |
if settings is None: | |
settings = {} | |
section_prefix_len = len(section_prefix) | |
section = dict([ (k[section_prefix_len:],v) for k,v in settings.items() if k[:section_prefix_len] == section_prefix ]) | |
for (k,v) in kw.items(): | |
if k not in section: | |
section[k] = v | |
dict.__init__(self, **section) |
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
--- 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 | |
try: |