[Twisted-web] pgasync (was: /freeform_post!!random causes exceptions)

Andrea Arcangeli andrea at cpushare.com
Thu Feb 17 19:48:57 MST 2005


On Thu, Feb 17, 2005 at 01:27:30PM -0600, J Turner wrote:
> Andrea,
> 
> Thanks for your suggestions; sorry I've taken so long to get back to
> them, but I haven't had time to work on pgasync until now... 

No problem, take your time. Sorry for not having discussed things last
time in IRC, but I was busy fighting with the mailing lists ;)

> I've patched that in, thanks.

You're welcome ;).

> This is fixed.

Ok fine!

> Nope, I don't think so.

Ok, I also couldn't find anything in the docs, perhaps %u should start
raising a deprecation warning, it's way confusing when two things do the
same thing and you never know if they're really the same thing ;)

> This is fixed as well.

fine, and this part I already fixed in my app too 8) I had no idea the ;
was added by the lib. it's actually the only part I changed after the
pgasync test, along with the compatibility code for the deferreds in
interaction that should allow me now to exchange psycopg2 with pgasync
back and forth with full compatibility.

> It's not trival to determine whether or not something gets resolved.  If
> it's a keyword argument situation, then I need to search the format
> string for some variation of %(keyword)s.  If it's just tuple-style,
> then I need to count the number of %s/d/whatevers and determine whether
> or not it's beyond the limit.
> 
> This seems ugly, and needlessly expensive for a corner case; I think the
> right answer is, only pass things to format() that are intended to be
> formatted and made safe for insertion into SQL.
> 
> But, then again, maybe I'm misunderstanding you.

You got it perfectly right, and I see your point, it'd be an unnecessary
slowdown to parse the string too.

But you could silenty convert to string if you can't find the conversion
type. In this case I'm suggesting to actually make it less strict but it
simplfy my code a lot.

I've tons of cases where I've a kwargs filled with stuff that is needed
by lots of chained deferreds. Now the sql one is using a few of the
kwargs entries, and then later on the email deferred uses other entries.

So if I can work with a single kwargs that has all the arguments
collected while the form action starts, the code is a lot simpler.

So my suggestion is not to give it up, but to try to convert to string,
and format it like string if __str__ did its job.

Comments? As soon as we sorted out this last bit, I'll give it a new
spin and perhaps it'll just work without a changing anything on my app.



More information about the Twisted-web mailing list