So, you want a linestring from each edge a polygon? I think I have an answer if that is true.
First: I would create a view that has all you polygons as linestrings. As you've pointed out, you can use ST_Boundary. (So that the second query is easy to write and read)
CREATE VEIW my_linestrings as
SELECT id,..., ST_BOUNDARY(the_geom)
FROM <yourtable>
Second: Since its a linestring you can use ST_POINTN to get the nth point and ST_MAKELINE to make a two segment line.
SELECT id,..., ST_MakeLine(ST_PointN(the_geom,x),ST_PointN(the_geom,x+1))
FROM my_linestrings
The ST_MakeLine will get you your linestring segment. You can make a loop in python to iterate though all the points. If this is something you need to do a lot, it would probably be best to create a new table with these segments.
Also, come join us at gis.stackexchange.com ;) This question is similiar to yours and uses SQL to create a series to loop through all the geometries (instead of python).