- 時間をおいてからもう一度おつなぎください
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 tastypie.api import Api | |
>>> | |
>>> api = Api(api_name="v1") | |
>>> api.register(TestResource()) | |
>>> api.urls | |
[<RegexURLPattern api_v1_top_level ^(?P<api_name>v1)/$>, | |
<RegexURLResolver [<RegexURLPattern apimethod_first_add_method ^(?P<resource_name>test)/first_add_method/$>, <RegexURLPattern apimethod_test_func ^(?P<resource_name>test)/test_func/$>, <RegexURLPattern api_dispatch_list ^(?P<resource_name>test)/$>, <RegexURLPattern api_get_schema ^(?P<resource_name>test)/schema/$>, <RegexURLPattern api_get_multiple ^(?P<resource_name>test)/set/(?P<pk_list>\w[\w/;-]*)/$>, <RegexURLPattern api_dispatch_detail ^(?P<resource_name>test)/(?P<pk>\w[\w/-]*)/$>] (None:None) ^(?P<api_name>v1)/>] |
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 django.conf.urls.defaults import url | |
from tastypie.utils import trailing_slash | |
from tastypie.resources import ( | |
ModelResource, | |
ALL | |
) | |
from apps import models as mdl | |
class TestResource(ModelResource): |
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
$ pip install eco |
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 eco | |
eco.compile(open("template.eco")) | |
# Out: u"function(...) {...}" | |
context = eco.context_for("Hello <%= @name %>") | |
context.call("render", {"name": "Sam"}) | |
# Out: u'Hello Sam' | |
eco.render("Hello <%= @name %>", name="world") |
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
$ sudo start flask-gunicorn | |
$ sudo stop flask-gunicorn |
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
description "Application server for flask-gunicorn" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
script | |
# ... environment settings | |
# ... | |
cd /path/to/basedir |
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
# decorator | |
def wrapper(cls): | |
def test(self): | |
return "decorator" | |
cls.test = test | |
return cls |
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
email = forms.EmailField( | |
label=_('E-mail'), | |
required=True, | |
widget=forms.TextInput(attrs={'size': '30'}) | |
) |
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 __init__(self, user=None, *args, **kwargs): | |
self.user = user | |
super(UserForm, self).__init__(*args, **kwargs) | |