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 tapioca.exceptions import ClientError, ServerError | |
from my_wrapper import MyWrapper | |
api = MyWrapper() | |
try: | |
r = api.my_resource().post(data={'test': 'data'}) | |
except ClientError as e: | |
print('This is a client error with status code %s' % e.client().response().status_code) | |
except ServerError as e: |
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
# executando algo antes da criação | |
class MeuTipo(type): | |
def __new__(cls, name, parents, dct): | |
print 'aqui!' | |
return super(MeuTipo, cls).__new__(cls, name, parents, dct) | |
class MinhaClasse(object): | |
__metaclass__ = MeuTipo | |
# trocando o nome da class |
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 BookSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Book | |
fields = ['title', 'author'] | |
class ExpandedBookMixin(object) | |
books = BookSerializer(many=True) |
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
var successCallback = function(result) { | |
console.log('audio callback ' + JSON.stringify(result)); | |
if (result.type==='progress') { | |
console.log('progress/duration/available - ' + result.progress + '/' + result.duration + '/' + result.available); // available not currently supported | |
} else if (result.type==='state') { | |
console.log('status - ' + result.state + '/' + result.description); | |
} else if (result.type==='error') { | |
console.log('error - ' + result.reason); | |
} else if (result.type==='current') { | |
console.log('current audio ' + JSON.stringify(result.audio)); |
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 rest_framework import permissions | |
class CustomViewPermission(permissions.BasePermission): | |
def has_permission(self, request, view): | |
if hasattr(view, 'custom_permission'): | |
return view.custom_permission(request) | |
return True |
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 fabric.api import * | |
from fabvenv import virtualenv, make_virtualenv | |
import server_config | |
env.roledefs = { | |
'django': server_config.DJANGO_HOSTS, | |
'django_provision': server_config.PROVISION_DJANGO_HOSTS, | |
} |
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 rest_framework import serializers | |
from core.serializers import ListWrapperSerializer | |
from .models import Band | |
class BandListSerializer(serializers.ModelSerializer): | |
class Meta: | |
model = Band |
NewerOlder