Simple XML creation with Python

I was so happy when I first found Amara. It was the easiest thing I had seen for creating XML with Python. It’s quite serious stuff because it can probably handle just about anything you throw at it. Then I heard about the wonderful web2py project. One of it’s beautiful aspects is XML generation, or [...]

PyAMF flying high

More python/Flex goodness in the works in the future perhaps? I really like Python… learning all the time with my web2py friends. I’d love to be able to combine this with Flex. Looks like it’s getting easier and easier. Now to combine this with Orbited…
Ted On Flex: The AMF Revolution
The growth [...]

Running postgresql createdb from batch without password prompt

As noted in this post, you need to change a line in pg_hba.conf to “trust” instead of “md5″ (no quotes) to be able to batch create tables. Note this is only for testing purposes and not recommended for production. The only reason is because I am running some benchmarks for web2py. I want to be [...]

Exporting a web2py table in XML

I recently wrote about exporting a Django database to xml. As a courtesy, Massimo, creator of web2py, put together a great little example for web2py
exporting in XML – web2py Web Framework | Google Groups

def export_xml(rows):
idx=range(len(rows.colnames))
colnames=[item.replace('.','_') for item in rows.colnames]
records=[]
[...]

web2py new website

Web2py is humming along and just got a redesigned front page. Nice, clean, and accessible. Gotta love the “complex” tutorial. Fits in a page!
web2py Enterprise Web Framework

A taste of web2py

Consider the following complete application which consists a model (which describes the data representation): db.py

1.2.

db=SQLDB(’sqlite://images.db’)db.define_table(‘image’,SQLField(‘file’,'upload’))

a controller (which describes the application logic and [...]

Export Django database to xml

Looking at this helps me understand more of what is going on internally with Django’s models. Using web2py is a bit more intuitive for getting some of this info so it’s probably not too hard to port the concept over… for a future exercise.
/home/siddhi: Export django database to an xml file
Export django database [...]

Formencode example

A full example, albeit with SQLObject, but the concept is pretty clear. With web2py, the form.validate would be followed with an explicit data insert. From the looks of the **form_result insert, form.validate returns a list of fields that can be directly inserted. The same format should be able to be used with Storm.
Handling Form data [...]

Predefined variables with lambda variables

This little line right here solved a problem. How do you dynamically assign a function to a variable to be invoked later but you need it to have a preset value? Define it when you assign it. I just didn’t know you could do that with lambda functions. Cool! This was used to update my [...]

Web2py’s interactive shell in iPython

This shell for web2py is quite cool. (You can look here for a Google tranlation of the original.) For those new to this stuff (like me), and if you’re working on something specific you can specify that in the environment. If you want to play with your model straight away, and it’s named ‘db’, you [...]

Simple web2py and Elixir

So I have a sample data set in a database created by web2py. After some experimentation I can access, modify and create data with Elixir/SQLAlchemy. Just some notes, like remember to encode web2py blobs with utf8 if you’re not going through web2py’s functions.
r=Recipe.query.all() r[0].instructions=u’some text to submit’.encode(‘utf8′) cb.session.flush()

And then something happend before this got pulished [...]

web2py interactive database sessions

After some experimentation, at least with the way I am working with web2py’s orm, the migrate command causes problems from an interactive shell session, i.e. within iPython.
So instead of
migrate=’some_file.table’

I have to use
migrate=’some_file.table’ if request.env else False

That’s no so bad. Previously I thought I would have to use
migrate=’some_file.table’ if __name__==’__builtin__’ else False

I didn’t like that. There [...]

Elixir: Simple sweet access with SQLAlchemy behind the scenes

I really like using web2py. I only have one major problem with developing with it. I like code completion and other good things that come with developing in an IDE.
First off, SqlSoup for SQLAlchemy. Very cool. It’s got runtime introspection which, in plain English, means that you can experiment with the database, seeing what [...]

Single place for settings for database

While using web2py, this is how I am working with databases now.
Make a new application called ‘init’ In init.models create an empty __init__.py file so you can import the settings. In init.models add create a settings.py file. in init.models.settings add:
DB_DEV=’dev connection string’ DB_STAGING=’staging connection string’ DB_PRODUCTION=’production connection string’
def getDBConnection(request): connect_string=None try: # [...]

Interactive web2py testing

web2py is a great web development app. It’s under heavy development and the creator answers tons of questions making many updates to the core code in very short order.
In the quest for TDD, now BDD, I wanted to be able to get an interactive [...]