This file contains 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 Test(object): | |
''' | |
this is a test object | |
''' | |
pass |
This file contains 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 Test(object): | |
''' | |
this is a test object | |
''' | |
x = 1 |
This file contains 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
page_tags = Table('page_tags', meta.metadata, | |
Column('page_id', Integer, ForeignKey('pages.id'), primary_key=True), | |
Column('tag_id', Integer, ForeignKey('tags.id'), primary_key=True) | |
) | |
class Metadata(AppBase, Base): | |
__tablename__ = 'metadata' | |
id = Column(Integer, primary_key=True) | |
page_id = Column(Integer, ForeignKey('pages.id')) |
This file contains 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 threading import Thread, BoundedSemaphore | |
class Worker(Thread): | |
def __init__(self, sema, target, args, kwargs): | |
super(Worker, self).__init__() | |
self.sema = sema | |
self.target = target | |
self.args = args | |
self.kwargs = kwargs |
This file contains 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
# Courtesy of http://norvig.com/python-iaq.html?a | |
class Struct(object): | |
def __init__(self, **kwargs): | |
self.update(kwargs) | |
def update(self, d): | |
self.__dict__.update(d) | |
def __repr__(self): | |
return 'Struct(%s)' % ', '.join('%s=%s' % (k, repr(v)) for (k,v) in vars(self).items()) |
This file contains 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 formencode import htmlfill %> | |
<%def name="formfill(values, errors=None, *args, **kwargs)"> | |
${htmlfill.render(capture(caller.body), values, errors or dict(), **kwargs) | n} | |
</%def> |
This file contains 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
"""The base Controller API | |
Provides the BaseController class for subclassing. | |
""" | |
from pylons.controllers import WSGIController | |
from pylons.templating import render_mako as render | |
from pylons import request, tmpl_context as c, response | |
from pylons.controllers.util import abort, redirect |
This file contains 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 asyncore, asynchat, logging, socket | |
log = logging.getLogger(__name__) | |
class Bot(asynchat.async_chat): | |
def __init__(self, nick, ident, realname): | |
asynchat.async_chat.__init__(self) | |
self.nick = nick | |
self.ident = ident |
This file contains 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 shutils, hashlib, os | |
from pylons import config, request | |
from webhelpers.html.tags import javascript_link, stylesheet_link | |
sha1 = lambda x : hashlib.sha1(x).hexdigest() | |
mtime = lambda path: os.path.stat(path).st_mtime | |
# FIXME factor out pylons adapter | |
class Glommer(object): |
This file contains 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 EnumItem(object): | |
def __init__(self, name, value): | |
self.name = name | |
self.value = value | |
class Enum(type): | |
def __init__(self, name, bases, dict): | |
super(Enum, self).__init__(name, bases, dict) | |
self.collection = {} |
OlderNewer