Coder Social home page Coder Social logo

yard's People

Contributors

dmfrancisco avatar laginha avatar rjvitorino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rchicoria

yard's Issues

bug in resource's fields

In a resource, defining the fields attribute, something like this:

fields = ('name', ('author', ('name','gender')) )

won't work properly. However, everything works fine if you do:

fields = ( ('author', ('name','gender')), 'name' )

The problem lies in the build_json_tree algorithm within yard's resources.

Bug with OR in Resource's __logic__

Imagine the scenario where a Resource can only have one of the attributes:

from yard.resources.decorators import validate
from yard import forms, resources

class Dude(resources.Resource):
    class Parameters:
        full_name = forms.CharParam()
        short_name = forms.CharParam()
        __logic__ = full_name | short_name

    @validate
    def index(self, request, params):
        if 'full_name' in params:
            print 'Dude can write his name: {}'.format(params['full_name'])
        else:
            print 'Need to find full name of Dude called {}'.format(params['short_name'])

Now imagine you call http://api.example.com/dudes without providing none of the parameters... It crashes when you try to do the params['short_name'], with KeyError at /dudes/ 'short_name' as its cause. It means params.is_valid()in the decorator @validate (yard/resources/decorators.py) is returning True, which means there's something wrong with the class OR in yard/forms/parameter.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.