So I’ve noticed there’s not one central place for Turbogears newbies to go to see a bunch of sample applications.
I’m trying to fix that.
To gauge interest, and as an easy/no hassle way to collect all these links, I started a public Google Doc that lists all the Turbogears examples on the web that I know about.
Check it out at: Turbogears Examples Public Google Doc.
At some point in time I’d love to work with the Turbogears team to make this part of their website, but I think showing them that there’s enough examples out there is an important first step.
Update: if Google docs gives you an error just hit refresh – it should sort itself out then.
I’m playing with Turbogears 2 more and more, and as part of this process I wanted to improve and codify my process for getting a new TG2 app up and running.
I also really like virtualenv, and am learning to love pip (mostly for the ease of requirements.txt).
I also know that the Installation for the Impatient make me, well, impatient. Ughh, 5 commands.
So I wanted to see if I could make this slightly better with pip, and I kind of did:
$ pip install -E tg2env -i http://www.turbogears.org/2.1/downloads/current/index/tg.devtools
$ source tg2env/bin/activate
$ paster quickstart my_wonderful_app
Two issues I found when trying to install TG2:
- You want tg.devtools, not Turbogears2: tg.devtools includes the tools to make new projects, where as the Turbogears package just includes the code to run a Turbogears app.
- Ultimately leaving out the -i part should work, but I ran into problems that way (had version conflicts with repoze.who), so ended up having to specify the package source with -i. It could be that these are solved by the time you read this.
or, to install the latest beta (at this point, 2.1b2)
$ pip install -E tg2env\
Ok, it’s still a lot of commands, but it can be done.
Hope this helps enable great Turbogears apps!
I find myself writing more and more sample projects for Turbogears 2. These sample projects are actually meant to be read by going through the commit history with GitX and reading the commit messages and reading the diffs.
Anyway, I’ve posted another one, on the form technology in Turbogears: Sprox/FormEncode. Clone it from its Github Repository
Turbogears uses Python’s logger module to perform logging operations. This has an advantage (it uses Python’s logger module) and an disadvantage (it uses Python’s logger module).
Be that as it may, here is the simplest configuration possible for you to log to a file (by default TG logs to your STDOUT device, which might not actually be what you want).
In (environment).ini (aka: development.ini)
Note: The format of logging section of this file follows the format laid down in the logging configuration file format section of the standard library documentation.
keys = console, file # added file (line was: "keys = console")
[logger_MY_TG_APP_NAME] # will be named whatever your TG app is named
level = DEBUG
handlers = file
qualname = MY_TG_APP_NAME
[handler_file] # added this section
class = FileHandler
args = ('MY_TG_APP_NAME/logs/foobar-debug.log', 'a+')
level = NOTSET
formatter = generic
Accessing this in your code
log = logging.getLogger("MY_TG_APP_NAME")
# .... code here ....