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 :-)<div>I figured their way must be the Pythonic way and went along with it.</div><div><br>
</div><div>I like your suggestion a lot more, it is definitely more OOP and cleaner.</div><div>Expect it to be reworked accordingly in the next release</div><div><br></div><div>Cheers</div><div>Jacek<br><br><div class="gmail_quote">
On Sun, Sep 4, 2011 at 12:01 AM, Glyph Lefkowitz <span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com">glyph@twistedmatrix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word"><br><div><div>On Sep 3, 2011, at 8:28 PM, Jacek Furmankiewicz wrote:</div><br><blockquote type="cite"><span style="border-collapse:separate;font-family:'Bitstream Vera Sans Mono';font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;font-size:medium"><div>
Any feedback is welcome</div></span></blockquote><br></div><div>Hi Jacek,</div><div><br></div><div>Great to see more development going into Twisted-based web stuff! :)</div><div><br></div><div>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:</div>
<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>app = CorePost()</div><div>...</div><div class="im"><div>@app.route("/validate/<int:rootId>/schema",Http.POST)</div></div>
</div><div class="im"><div><div>@validate(schema=TestSchema)</div></div><div><div>def postValidateSchema(request,rootId,childId,**kwargs):</div></div><div><div> '''Validate using a common schema'''</div>
</div><div><div> return "%s - %s - %s" % (rootId,childId,kwargs)</div></div></div></blockquote><div><br>You could do:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>
class MyPost(CorePost):</div><div class="im"><div> @route("/validate/<int:rootId>/schema",Http.POST)</div></div></div><div><div> @validate(schema=TestSchema)</div></div><div><div> def postValidateSchema(self,request,rootId,childId,**kwargs):</div>
</div><div class="im"><div><div> '''Validate using a common schema'''</div></div><div><div> return "%s - %s - %s" % (rootId,childId,kwargs)</div></div></div></blockquote><div>
<br>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.</div>
<div><br></div><div>In other words, global variables are bad, and this looks like it depends rather heavily on them.</div><div><br></div><div>Any thoughts on this? Am I missing the point?</div><div><br></div><div>Thanks,</div>
<div><br></div><font color="#888888"><div>-glyph</div><div><br></div></font></div><br>_______________________________________________<br>
Twisted-web mailing list<br>
<a href="mailto:Twisted-web@twistedmatrix.com">Twisted-web@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web</a><br>
<br></blockquote></div><br></div>