The point is that I more or less blindly copied the Flask API when starting
on this, due to relative lack of experience with Python :-)
I figured their way must be the Pythonic way and went along with it.

I like your suggestion a lot more, it is definitely more OOP and cleaner.
Expect it to be reworked accordingly in the next release

Cheers
Jacek

On Sun, Sep 4, 2011 at 12:01 AM, Glyph Lefkowitz <[email protected]>wrote:

>
> On Sep 3, 2011, at 8:28 PM, Jacek Furmankiewicz wrote:
>
> Any feedback is welcome
>
>
> Hi Jacek,
>
> Great to see more development going into Twisted-based web stuff! :)
>
> However, I do have one question.  Maybe I'm missing something about the way
> Flask does things, but it seems very odd to me that the decorators you're
> using are applied to global functions, rather than instances of an object.
>  For example, instead of:
>
> app = CorePost()
> ...
> @app.route("/validate/<int:rootId>/schema",Http.POST)
> @validate(schema=TestSchema)
> def postValidateSchema(request,rootId,childId,**kwargs):
>     '''Validate using a common schema'''
>     return "%s - %s - %s" % (rootId,childId,kwargs)
>
>
> You could do:
>
> class MyPost(CorePost):
>     @route("/validate/<int:rootId>/schema",Http.POST)
>     @validate(schema=TestSchema)
>     def postValidateSchema(self,request,rootId,childId,**kwargs):
>         '''Validate using a common schema'''
>         return "%s - %s - %s" % (rootId,childId,kwargs)
>
>
> This would allow for re-usable objects; for example, rather than having a
> "blog article create" API (sorry for the uninspired example, it's late) for
> your entire site, you would have a "article create" API on a "Blog", which
> would enable you to have multiple Blog objects (perhaps with different
> authors, in different permission domains, etc).  This would also make
> re-using the relevant objects between different applications easier.
>
> In other words, global variables are bad, and this looks like it depends
> rather heavily on them.
>
> Any thoughts on this?  Am I missing the point?
>
> Thanks,
>
> -glyph
>
>
> _______________________________________________
> Twisted-web mailing list
> [email protected]
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>
>
_______________________________________________
Twisted-web mailing list
[email protected]
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Reply via email to