Tag: turbogears
Making TurboGears and Authorize.net play nice together
by Seth on Jul.18, 2009, under Python, Web Development
I recently had to wire up an Authorize.net form for a TurboGears project I’m building, and since I’m a bit new to custom form validation in TG I had quite a bit of trouble figuring out the “right” way to do it.
The goal was to get the form to go through two layers of validation before passing:
- Use the validation packages provided by TG (tw.forms and formencode)
- If the first layer of validation passes, try to run the authorize.net charge. If this returns a response code of 1 (approved) then all validation has passed. Otherwise, invalidate the form and flash the authorize.net error.
tw.forms and formencode are awesome packages, but at first glance there didn’t seem to be “one obvious way” to do things. I found the documentation and tutorials to be scant at best, and eventually went to the TurboGears mailing list for help. In spite of the fact that I’d probably give TurboGears a “C” at best for its documentation (not to mention the availability of “verbose” tutorials), the folks on the mailing list and IRC channel (when it’s actually active) seem to be quite helpful.
Eventually (and with additional help from Google’s source code search) I was able to hack together something that worked as planned, and was overjoyed to observe chained validators in action. Below is some example code provided for your hacking pleasure. To download the full example file, see the links at the bottom of the post. (continue reading…)
Introducing TurboGears 2
by Seth on Jun.09, 2009, under Python, Web Development
I’m the type of person who is a bit anal about trying to use what I think is “the right tool for the job.” This is something I think my Dad passed down to me (I can’t tell you how many times I was scolded with that phrase as a kid—usually having something to do with me trying to hammer an object with anything but a hammer); and it influences my world of development heavily. Because of this, I often find myself using a number of different programming languages and technologies at any given time for various projects. A shell script is perfect when you need something quick & dirty. PHP makes adding logic to HTML a piece of cake. And then there’s my new personal favorite: Python.
Ok, let me back up before I get ahead of myself… (continue reading…)