Introducing blogcdb

Monday, December 22, 2008

I have created a new project at github.

It's blogcdb ( a blog engine that uses couchdb ).

The blog engine is made with turbogears 2, a very good python web framework.

Also uses dojo javascript framework for some fancy stuff. Dojo version 1.2.3 is included.

To store blog posts, comments and attachments , the erlang based couchdb document database engine is used.

Requirements:

couchdb-python module by Christopher Lenz and Jan Lenhardt.
python 2.6
turbogears 2 : trunk version which also needs a lot of modules.
dojo 1.2.3 ( included ).
couchdb ( svn truk version ) available from apache software foundation.
erlang/otp
mozilla's spidermonkey.

Get blogcdb at http://www.github.com/batok/blogcdb

A wxpython GUI interface to a blog.

Wednesday, December 10, 2008



I have created a github project with the name couchdb-wxpython.


The project is a python script that uses:

wxpython ( a python module for GUI which is cross-platform. It is a wrapper for wxwidgets ).

couchdb , a document oriented database to store blogposts , comments and attachments.


The program can also take screenshots and store them as attachments into couchdb.

New attachment handling in couchdb-python module

Tuesday, September 09, 2008

I've been trying out the new methods for the Database class in couchdb-python, in the svn repository.

I tried put_attachment.

Guess you already have a couchdb database called blog. To get a reference to the db you have to...


from couchdb.schema import *


class Post(Document):
author = TextField()
subject = TextField()
content = TextField()
tags = ListField( TextField() )
comments = ListField( DictField(Schema.build(
comment_author = TextField(),
comment = TextField(),
comment_date = DateTimeField()
)))
date = DateTimeField()


from couchdb import Server
from datetime import datetime
import binascii
s = Server("http://127.0.0.1:5984/")
s.create("blog")
blog = s["blog"]
p = Post( author = "Me", subject = "Whatever for the subject ", content = "Any content",date = datetime.now(), tags = ["Python", "Couchdb", "Blog"])

p.store(blog)

f = open("apythonfile.py", "rb")
foo = binascii.b2a_base64(f.read()) # this convert the content of the file to a encode 64 string

#put_attachment only works right now with an encoded string as I see and with a dictionary object for the document ( first parameter ) and not for a Document instance as used here , so...


blog = s["blog"]
adoc = blog[p.id]

and finally call the method...

blog.put_attachment( adoc, "apythonfile.py", foo, "text/python")

#you can't do blog.put_attachment( p, "apythonfile.py", f, "text/python") which I taught by reading the doc inside the method.

Yet another python frameworks' "which one is best for my project"

Friday, July 18, 2008

Python web frameworks ( or libraries ) which I have used for real world projects.

1 - Zope 2 /Plone. This was the first one. Tal template system was nice to learn. Throw the web zope application server update is nice for designers but not for development ( despite I used cadaver webdav command line client which also uses vim ). In general, I didn't like Zope, because is not very pythonic.

2 - Nevow. This came second after asking in IRC channels about a good one framework to use. A guy convinced me to try it. Nevow is the swiss army knife of the python web frameworks. You can do the impossible with it , but it's very complex for simple , business like endeavors.

3 - After Nevow I gave Django a try and liked it. At the same time I gave Turbogears 1 a try after watching the wiki in 20 minutes screencast by TG's author Kevin Dangoor. Then I decided on embrace TG 1.

4. When TG 1.0 felt short to one of my project expectations I decided to use Pylons which I liked a lot. The problem with Pylons is that , becoming another "swiss army knife" as Nevow, simple things were ackward to do.

5 - Now it's time of a happy convergence : TG simplicity + Pylons , that is , Turbogears 2. So I have to say good bye to cherrypy , kid and sqlobject . Welcome Paste, gengshi, webob, sqlalchemy, toscawidgets, beaker, etc. At this very moment I think TG2 is "Easy Pylons".