Posts

Singleton pattern for a database connection

I think I understood Singleton pattern, any suggestion? from pyPgSQL import PgSQL class Database(object): _sigletons = {} def __new__(cls): if cls not in cls._sigletons: cls._connection = PgSQL.connect(database='dbname', user='username', password='passwd', host='hostname') cls._sigletons[cls] = object.__new__(cls) pass return cls._sigletons[cls] def __init__(self): self.connection = Database._connection pass def cursor(self): return self.connection.cursor() #other methods follows here #just to test logjam

Moving from Python to Java :(

For last 9 months my company was developing an enterprise application. Our main language was Python. Its going to implement all over India by next few months. Next month we will start our new project, Java will be our main language. Now I started refreshing my Java. And this is one thought came to me today, when I looked into Strings in Java. One of Python's primary design principle is that: "Special cases aren't special enough to break the rules." That is, the language should avoid having privileged features that you can't reuse for other purposes. The consequence of this principle is, more generalisation of syntax and semantics of a language. In Python : (of course, there are better ways) age = 9 print "He is " + str(age) + " years old." In Java: int age = 9; String s = "He is " + age + " years old."; System.out.println(s); Concatenating string and integer like this is possible in Java, because it is a "spec...

Zope3 first look

Just now I downloaded Debian packages of Zope X3 from: http://people.debian.org/~doko/zope3/ First I tried to install zope3-lib_3.0.0-4_i386.deb but it shows dependency for python2.3-zopeinterface, then I installed python2.3-zopeinterface_3.0.0-4_i386.deb after that zope3-lib_3.0.0-4_i386.deb (I had already installed Zope 2.7 ) To work Zope 3 for me, I did following things too: 1. Edited /usr/lib/zopex3/bin/mkzopeinstance replced python2.4 with python2.3 2. #cd /usr/lib/zopex3/zopeskel (I don't know, this is necessary or not) #python ../bin/mkzopeinstance -u baiju:password -d /tmp/zope3 3. Edited /tmp/zope3/etc/zope.conf (Changed ports to 70XX) type HTTP address 7080 type FTP address 7021 4. #/tmp/zope3/bin/runzope Now I opened http://localhost:7080 in Fire Fox , I can see Zope 3 running :)

A dry sunday

To I came to my office very early to do some urgent works, but I completed within two hours. And then started going trough lots blogs found in planetpython.org and some mailing lists. Now I am leaving..

Culebra, my working copy

I am plannig to put my working copy of Culebra here : http://baijum81.freezope.org/downloads/culebra.tar.bz2

Mumbai journey

I was in Mumbai last week, I went there as part of my company's work.

Culebra IDE

http://developer.berlios.de/projects/culebra/ This project originally called grad (started by fernado), then I renamed to grade and hosted at sarovar.org, now it is moved to berlios.de with a new name 'Culebra' which is a spanish word with meaning snake (I don't know which snake). Actually Python has nothing to do with reptiles, but I think many pythonistas like snake names. I am a member of BangPypers (http://www.bangpypers.org), they are planning a project called 'Uraga' which are reptiles with super powers in indian classics. But I don't like reptiles, but the name 'Culebra' sounds very good. Hope it will become a very successful project.