March 2nd, 2006


2
Mar 06

PN Screenshots

The screenshots section of the Programmer’s Notepad web site needs re-doing. Do you have any interesting screenshots showing your use of PN? If so, please mail them to me (ss at pnotepad org) or blog them and ping this post.


2
Mar 06

Fancy TurboGears “Flash” Messages

Lee has a great article on making the TurboGears “flash” functionality more useful. “tg_flash” or “turbogears.flash” in 0.9 is a method used to set a status message on the next page to be displayed. In its default form this allows you to send some plain text or HTML to the page.

I was looking for a way to pass more information using this mechanism to indicate success or failure of an operation so that the message can be styled properly and Lee presents a great solution to this problem:

Fancy status messages using tg_flash


2
Mar 06

Forms with values in TurboGears

So 0.9a1 supports forms, that’s great. However, I found getting hold of suitable examples for use in the real world difficult. The examples all show how to create a form and display it, and also how to validate the information in the response. What they didn’t show, is how to get information into the form when it’s displayed.

So here is a quick sample showing how it’s done:

In your python code, you build up a dictionary of the field values:

class SomeFields(widgets.WidgetsDeclaration):
    name = widgets.TextField(validator=validators.NotEmpty)
    email = widgets.TextField(validator=validators.Email())

the_form = widgets.TableForm(fields=SomeFields(), submit_text="Post")

class Root(RootController):
    @expose(template=".templates.index")
    def index(self):
        values = {"name":"simon", "email":"me@there.com"}
        return dict(form=the_form, values=values)

Then in your kid template, you pass the values in to the form:

${form(action="submitForm", value=values)}


2
Mar 06

TurboGears 0.9a1 Released

TurboGears is a “mega-framework” collecting a number of well-known web architecture components and glueing them together to form a productive environment for web development.

I’m using TurboGears at work to develop a service management and configuration application, and had held off implementing things like users, authentication and configuration forms in order to wait for 0.9 which brings built in support for all of these things.

Thankfully, the first test release of 0.9 has now been packaged up and is ready to go, I’ve upgraded my project to work with it and it seems to be pretty good: Get TurboGears 0.9a1 here.

Note, the upgrade instructions didn’t work for me, I had to change this line:

easy_install -f
http://www.turbogears.org/preview/download/index.html TurboGears

to this:

easy_install -U -f
http://www.turbogears.org/preview/download/index.html TurboGears