Jaymon / endpoints

Lightweight REST api backend framework that automatically maps urls to python modules and classes
MIT License
29 stars 10 forks source link

param default can be better #13

Closed Jaymon closed 10 years ago

Jaymon commented 10 years ago
@decorators.param("before_created", required=False, default=datetime.datetime.utcnow())

the default will only be run once, so it's not per request like you would expect, there are 2 ways to fix this:

@decorators.param("before_created", required=False, default=datetime.datetime.utcnow)

I can then have the code check to see if default is callable and if it is then it will run it everytime the decorated method is called. Or I could add a new default_cb param that would do the same thing, it would just be more explicit. I think I like checking default for a callback is better, even though it would make it so default could never be a function value, I'm not sure that really matters?