Skip to content

Instantly share code, notes, and snippets.

View aodag's full-sized avatar

Atsushi Odagiri aodag

View GitHub Profile
@aodag
aodag / wsgihello.py
Created August 27, 2011 06:00
Greeting message wsgi application with various wsgi components
import os
import formencode
from formencode import validators
from formencode import htmlfill
from routes import Mapper
from mako.lookup import TemplateLookup
from webob import Response
@aodag
aodag / index.mak
Created September 27, 2011 03:09
pyramid on tornardo with py3
<html>
<body>
<h1>Hello</h1>
</body>
</html>
@aodag
aodag / README.rst
Created December 28, 2011 02:10 — forked from oyakata/README.rst
かけ算

result

♥♥

Press ENTER or type command to continue

@aodag
aodag / gist:1579425
Created January 8, 2012 19:41
pythonの組み込み型に見られる特徴
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__dict__'
>>> a = 10
>>> a.__dict__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute '__dict__'
>>> a = 1.0
@aodag
aodag / views.py
Created February 4, 2012 11:05
pyramid deform fileupload sample
import colander as c
import deform.widget as w
from deform.form import Form
from deform.schema import FileData
import os
here = os.path.dirname(__file__)
class Store(dict):
def preview_url(self, name):
class RegexDispatch(object):
def __init__(self, patterns):
self.patterns = patterns
def __call__(self, environ, start_response):
script_name = environ.get('SCRIPT_NAME', '')
path_info = environ.get('PATH_INFO', '')
for regex, application in self.patterns:
match = regex.match(path_info)
@aodag
aodag / myenv.py
Created September 5, 2012 01:35
installing distribute after pyenv created
#!/opt/python-3.3.0rc1/bin/python3.3
import venv
import sys
import argparse
import subprocess
import os
here = os.path.dirname(__file__)
@aodag
aodag / statemachine.py
Created September 9, 2012 19:00
State Machine
# -*- coding:utf-8 -*-
from zope.interface import Interface, directlyProvides
from zope.interface.adapter import AdapterRegistry
class IStateChangeSubscriber(Interface):
def __call__(event):
""" """
class StateEvent(object):
""" implementation of every state events """
@aodag
aodag / hello.py
Created September 28, 2012 04:27
wtform + GETパラメータ
from werkzeug.wrappers import Request, Response
from wtforms import Form
import wtforms.fields as f
import wtforms.validators as v
class GreetingForm(Form):
message = f.TextField(u'Message', validators=[v.Required()])
@Request.application
@aodag
aodag / helpers.py
Created January 21, 2013 05:01
pyramid 小物シリーズ
def add_helper(config, name, helper):
helper = config.maybe_dotted(helper)
def before_render(event):
event[name] = helper
config.add_subscriber(before_render,
'pyramid.events.BeforeRender')
def includeme(config):
config.add_directive("add_helper", ".add_helper")