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
location ~ /\+f/ { | |
try_files /+files$uri @proxy_to_app; | |
} | |
location ~ /\+f/ { | |
internal; | |
root /path/+files$uri; | |
try_files /+files$uri @proxy_to_app; |
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
# settings for an application: | |
from django.conf import settings | |
SOME_ATTR = getattr(settings, 'APP_SOME_ATTR', 'Default value') |
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
def post(self, request, format=None): | |
serializer = self.get_serializer(data=request.DATA, files=request.FILES) | |
if serializer.is_valid(): | |
some_function_to_save(serializer.object) | |
return Response(serializer.data, status=status.HTTP_201_CREATED) | |
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
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 unittest | |
class MetaTest(type): | |
def __new__(cls, name, bases, attrs): | |
for k, v in attrs['generation_data'].items(): | |
def test_function(self): | |
self.assertTrue(v[0]**2, v[1]) | |
attrs['test_%s' % k] = test_function | |
return super(MetaTest, cls).__new__(cls, name, bases, attrs) |
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 RequestTransport(xmlrpclib.Transport, object): | |
def __init__(self, use_datetime=0, proxies=None): | |
super(RequestTransport, self).__init__(use_datetime) | |
self.session = requests.Session() | |
self.configure_requests(proxies=proxies) | |
def configure_requests(self, proxies=None): | |
self.session.headers.update({ | |
'Content-Type': 'text/xml', |
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 UserSerializer(serializers.HyperlinkedModelSerializer): | |
class Meta: | |
model = User | |
fields = ('url', 'username', 'snippets') | |
class SnippetViewSet(viewsets.ModelViewSet): | |
queryset = Snippet.objects.all() | |
serializer_class = SnippetSerializer | |
permission_classes = (permissions.IsAuthenticatedOrReadOnly) |
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
OGGING = { | |
'version': 1, | |
'disable_existing_loggers': False, | |
'handlers': { | |
'mail_admins': { | |
'level': 'ERROR', | |
'class': 'django.utils.log.AdminEmailHandler' | |
}, | |
'console': { | |
'level': 'DEBUG', |
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
MacBook-Air-de-Xavier:tmp xordoquy$ mkvirtualenv | |
mkvirtualenv mkvirtualenv_help | |
MacBook-Air-de-Xavier:tmp xordoquy$ mkvirtualenv test | |
New python executable in test/bin/python | |
Installing setuptools.............done. | |
Installing pip...............done. | |
(test)MacBook-Air-de-Xavier:tmp xordoquy$ pip install -r req.txt | |
Downloading/unpacking numpy (from -r req.txt (line 1)) | |
Downloading numpy-1.7.1.zip (3.1Mb): 3.1Mb downloaded | |
Storing download in cache at /Users/xordoquy/.pip/cache/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fn%2Fnumpy%2Fnumpy-1.7.1.zip |
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 json | |
>>> json.dumps({1: b'\xd1\x88\xd1\x82'}) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/__init__.py", line 226, in dumps | |
return _default_encoder.encode(obj) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 188, in encode | |
chunks = self.iterencode(o, _one_shot=True) | |
File "/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/json/encoder.py", line 246, in iterencode | |
return _iterencode(o, 0) |
NewerOlder