Tidbits @ Kassemi

A collection of opinions, thoughts, tricks and misc. information.

Wednesday, November 15, 2006

 

do away with pkg-config and combine your libraries

Short rant, but to hell with gnome for their libraries and dependencies. Just package glib, pango, atk, gtk, gtkmm, glibmm, and every other freaking pain in the ass library I need to install to get the gimp up and running in ONE thing!

Pat from Slackware thought the same thing, and I'm sure the folks over at Freerock curse your name every time a new library comes out. ARGH!

Sunday, October 29, 2006

 

Sample registration form

Heh. The framework's getting MUCH easier to use... And it's still not quite where I want it... Here's a quick little sample, a user registration process. This is the ENTIRE thing. Form validation, generation, database entry,
etc. We've even got a great captcha generator that handles them fairly transparently.

A focus on finishing up unit tests comes tomorrow after work... After that I'll be doing a separation between the server and framework, and then a few touchups and additions to the library and it's ready for the first alpha release... (it might be a while).


import kepty
import datetime
from kepty.lib.forms import *
from kepty.lib.scaffolding import validate_input

# Create a form...
class RegisterForm(FormSkeleton):
username = CharWidget(fv=Validator(min_length=2))
password = PassWidget(fv=Validator(field_match='password_confirm'))
password_confirm = PassWidget()
email = CharWidget(fv=Validator(is_email=True))
birthdate = DateTimeWidget(fv=Validator(max_age=18))
description = TextWidget(fv=Validator(min_length=2))
captcha = CaptchaWidget(fv=Validator(valid_captcha=True))

# Creates a quick template file... We delete this command as soon as it's been run.

RegisterForm().quick_start('/home/james/Projects/kepty/base/templates/tester/registration_form.tmpl')

@validate_input(error='same')
@kepty.expose(template='registration_form.tmpl')
def register(request, errored=False, registration=RegisterForm):
if registration == None:
return dict(RegisterForm=RegisterForm())

if(errored):
return dict(RegisterForm=registration)

user = kepty.lib.database.ORM.create('users')
user.update(registration.all())
user.sync()

return "Thanks! You've been registered, %s!" % user.username


application = kepty.make_app(
(r'^/register$', register)
)

kepty.mount('/tester', application, 'tester')


Archives

August 2005   September 2005   October 2005   November 2005   December 2005   January 2006   February 2006   March 2006   April 2006   June 2006   July 2006   August 2006   September 2006   October 2006   November 2006  

This page is powered by Blogger. Isn't yours?