<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Sep 3, 2011, at 8:28 PM, Jacek Furmankiewicz wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-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; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 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. &nbsp;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. &nbsp;For example, instead of:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>app = CorePost()</div><div>...</div><div>@app.route("/validate/&lt;int:rootId&gt;/schema",Http.POST)</div></div><div><div>@validate(schema=TestSchema)</div></div><div><div>def postValidateSchema(request,rootId,childId,**kwargs):</div></div><div><div>&nbsp; &nbsp; '''Validate using a common schema'''</div></div><div><div>&nbsp; &nbsp; return "%s - %s - %s" % (rootId,childId,kwargs)</div></div></blockquote><div><br class="Apple-interchange-newline">You could do:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div>class MyPost(CorePost):</div><div>&nbsp; &nbsp; @route("/validate/&lt;int:rootId&gt;/schema",Http.POST)</div></div><div><div>&nbsp; &nbsp; @validate(schema=TestSchema)</div></div><div><div>&nbsp; &nbsp; def postValidateSchema(self,request,rootId,childId,**kwargs):</div></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; '''Validate using a common schema'''</div></div><div><div>&nbsp; &nbsp; &nbsp; &nbsp; return "%s - %s - %s" % (rootId,childId,kwargs)</div></div></blockquote><div><br class="Apple-interchange-newline">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). &nbsp;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? &nbsp;Am I missing the point?</div><div><br></div><div>Thanks,</div><div><br></div><div>-glyph</div><div><br></div></body></html>