Robert Forkel | 3 Dec 16:56

problem with port setting for psycopg 1.1.21

hi,
just installed SQLObject-0.7.2b1-py2.4 on Ubuntu Dapper. PostgreSQL
8.1 listens on port 5433 by default, and psycopg 1.1.21 is installed.
Unfortunately, psycopg's connect function expects the port as str and
not as int:

>>> c.makeConnection()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py",
line 110, in makeConnection
    conn = self.module.connect(**self.dsn_dict)
TypeError: argument 4 must be string, not int

The following patch

root <at> rostrum:/etc/postgresql# diff -Naur
/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/old_pgconnection.py
/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py
--- /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/old_pgconnection.py
 2006-12-03 16:51:12.000000000 +0100
+++ /usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/pgconnection.py
     2006-12-03 16:28:16.000000000 +0100
@@ -107,6 +107,8 @@
             if self.use_dsn:
                 conn = self.module.connect(self.dsn)
             else:
+                if 'port' in self.dsn_dict:
+                    self.dsn_dict['port'] = str(self.dsn_dict['port'])
                 conn = self.module.connect(**self.dsn_dict)
(Continue reading)

Oleg Broytmann | 3 Dec 17:32
X-Face
Picon
Favicon

Re: problem with port setting for psycopg 1.1.21

Hello!

On Sun, Dec 03, 2006 at 04:56:35PM +0100, Robert Forkel wrote:
> @@ -107,6 +107,8 @@
>              if self.use_dsn:
>                  conn = self.module.connect(self.dsn)
>              else:
> +                if 'port' in self.dsn_dict:
> +                    self.dsn_dict['port'] = str(self.dsn_dict['port'])
>                  conn = self.module.connect(**self.dsn_dict)

   Thank you. I don't think this is the best place to fix that. Why not fix
the place where the dsn_dict has been created? (Line 48.)

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Robert Forkel | 3 Dec 17:55

Re: problem with port setting for psycopg 1.1.21

You are right. line 48 would be the better place. Unfortunately, i
just found the following:
sqlobject 0.7.0 had the port converted to a string, but using this
with psycopg 2.0b8 gives:
TypeError: an Integer is required
so i really don't know what to do. It would be possible to distinguish
between psycopg major versions.

On 12/3/06, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
> Hello!
>
> On Sun, Dec 03, 2006 at 04:56:35PM +0100, Robert Forkel wrote:
> > @@ -107,6 +107,8 @@
> >              if self.use_dsn:
> >                  conn = self.module.connect(self.dsn)
> >              else:
> > +                if 'port' in self.dsn_dict:
> > +                    self.dsn_dict['port'] = str(self.dsn_dict['port'])
> >                  conn = self.module.connect(**self.dsn_dict)
>
>    Thank you. I don't think this is the best place to fix that. Why not fix
> the place where the dsn_dict has been created? (Line 48.)
>
> Oleg.
> --
>      Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
(Continue reading)

Robert Forkel | 3 Dec 18:00

Re: problem with port setting for psycopg 1.1.21

one more datapoint: psycopg 1.99.13 expects a string, too. so at
least, one could differentiate based on psycopg major versions, i.e.
psycopg.__version__.split('.')[0] == '1'
or something like that.

On 12/3/06, Robert Forkel <xrotwang <at> googlemail.com> wrote:
> You are right. line 48 would be the better place. Unfortunately, i
> just found the following:
> sqlobject 0.7.0 had the port converted to a string, but using this
> with psycopg 2.0b8 gives:
> TypeError: an Integer is required
> so i really don't know what to do. It would be possible to distinguish
> between psycopg major versions.
>
> On 12/3/06, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
> > Hello!
> >
> > On Sun, Dec 03, 2006 at 04:56:35PM +0100, Robert Forkel wrote:
> > > @@ -107,6 +107,8 @@
> > >              if self.use_dsn:
> > >                  conn = self.module.connect(self.dsn)
> > >              else:
> > > +                if 'port' in self.dsn_dict:
> > > +                    self.dsn_dict['port'] = str(self.dsn_dict['port'])
> > >                  conn = self.module.connect(**self.dsn_dict)
> >
> >    Thank you. I don't think this is the best place to fix that. Why not fix
> > the place where the dsn_dict has been created? (Line 48.)
> >
> > Oleg.
(Continue reading)

Oleg Broytmann | 3 Dec 19:09
X-Face
Picon
Favicon

Re: problem with port setting for psycopg 1.1.21

On Sun, Dec 03, 2006 at 06:00:28PM +0100, Robert Forkel wrote:
> one more datapoint: psycopg 1.99.13 expects a string, too. so at
> least, one could differentiate based on psycopg major versions, i.e.
> psycopg.__version__.split('.')[0] == '1'
> or something like that.

   I see. Please create a patch, I will test and apply it.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Robert Forkel | 3 Dec 19:36

Re: problem with port setting for psycopg 1.1.21

the attached patch is tested with psycopg 2.0b8 and 1.1.21.

On 12/3/06, Oleg Broytmann <phd <at> phd.pp.ru> wrote:
> On Sun, Dec 03, 2006 at 06:00:28PM +0100, Robert Forkel wrote:
> > one more datapoint: psycopg 1.99.13 expects a string, too. so at
> > least, one could differentiate based on psycopg major versions, i.e.
> > psycopg.__version__.split('.')[0] == '1'
> > or something like that.
>
>    I see. Please create a patch, I will test and apply it.
>
> Oleg.
> --
>      Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
>            Programmers don't die, they just GOSUB without RETURN.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> sqlobject-discuss mailing list
> sqlobject-discuss <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
---
/usr/lib/python2.4/site-packages/SQLObject-0.7.2b1-py2.4.egg/sqlobject/postgres/old_pgconnection.py	2006-12-03
(Continue reading)

Oleg Broytmann | 3 Dec 20:23
X-Face
Picon
Favicon

Re: problem with port setting for psycopg 1.1.21

On Sun, Dec 03, 2006 at 07:36:06PM +0100, Robert Forkel wrote:
> the attached patch is tested with psycopg 2.0b8 and 1.1.21.

   Thank you! I hope to submit it to SVN tomorrow.

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Jonathan Wight | 4 Dec 01:20
Favicon

InheritableSQLObject and MultipleJoins

I've got a three level inheritance model that looks a little like this:

class Node(InheritableSQLObject):
	parent = ForeignKey('Node', default = None)
	children = MultipleJoin('Node', joinColumn = 'parent_id')

class ContentNode(Node):
	content = StringCol(default = None)

class Page(ContentNode):
	comments = MultipleJoin('Comment', joinColumn = 'parent_id')

class Comment(ContentNode):
	pass

And create some test data like so:

thePage = Page(content = 'Page 1')
theComment = Comment(content = 'Comment 1')
theComment.parent = thePage

When I print the children of the page, everything is correct (i.e.  
the one comment is listed)

print thePage.children

When I try to print the comments of the page, I get an error:

print thePage.comments

(Continue reading)

lola shaw | 3 Dec 14:26

Are you requiring less $ worries and additional flexibility in your life

Dear Tom,

6 months ago I was let go from my employment I held for many years.

Its very hard to thank you enough for starting  me in this new profession.
You have given me a new beginning on life.  Already taking home twice as
much as I took home in my old job.  

I have a brand new Mercedes. Taking home 165,000US in 18 months. I am
having a great time in this profession. It is a blast and I am a hero to the
judges and to my customers. What an outstanding business to be in.

Following exactly what your training recommends me to do, is proceeding
better than I ever dreamed possible.  I go to the local court house and
locate all of the customers I can handle. 

I avail myself of your advanced reporting services to find all items which
can be garnished. Using your fill in the blank forms I send them thru the
post office to the appropriate firms. Then the funds arrive to my PO Box. 
Its like magic.  Its so exciting opening up the payments as they arrive.. 

Please provide this letter to others.  This profession is so massive it
needs many more of us assisting the courts and the  people who have been
harmed.

I can take a holiday when ever I so desire to do so.  Bahamas and Holland
this year. 

Sincerely,
 E.    Ontario    
(Continue reading)

Oleg Broytmann | 4 Dec 11:22
X-Face
Picon
Favicon

Re: InheritableSQLObject and MultipleJoins

On Sun, Dec 03, 2006 at 07:20:30PM -0500, Jonathan Wight wrote:
> Is MultipleJoin not smart enough to understand instances of  
> InheritableSQLObject? And if not is this behavior a bug that will be  
> fixed in the future?

   Hard to say. I need to look at it it deeper...

Oleg.
--

-- 
     Oleg Broytmann            http://phd.pp.ru/            phd <at> phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane