sqlobject-discuss Mailing List for SQLObject (Page 397)
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
You can subscribe to this list here.
2003 |
Jan
|
Feb
(2) |
Mar
(43) |
Apr
(204) |
May
(208) |
Jun
(102) |
Jul
(113) |
Aug
(63) |
Sep
(88) |
Oct
(85) |
Nov
(95) |
Dec
(62) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(38) |
Feb
(93) |
Mar
(125) |
Apr
(89) |
May
(66) |
Jun
(65) |
Jul
(53) |
Aug
(65) |
Sep
(79) |
Oct
(60) |
Nov
(171) |
Dec
(176) |
2005 |
Jan
(264) |
Feb
(260) |
Mar
(145) |
Apr
(153) |
May
(192) |
Jun
(166) |
Jul
(265) |
Aug
(340) |
Sep
(300) |
Oct
(469) |
Nov
(316) |
Dec
(235) |
2006 |
Jan
(236) |
Feb
(156) |
Mar
(229) |
Apr
(221) |
May
(257) |
Jun
(161) |
Jul
(97) |
Aug
(169) |
Sep
(159) |
Oct
(400) |
Nov
(136) |
Dec
(134) |
2007 |
Jan
(152) |
Feb
(101) |
Mar
(115) |
Apr
(120) |
May
(129) |
Jun
(82) |
Jul
(118) |
Aug
(82) |
Sep
(30) |
Oct
(101) |
Nov
(137) |
Dec
(53) |
2008 |
Jan
(83) |
Feb
(139) |
Mar
(55) |
Apr
(69) |
May
(82) |
Jun
(31) |
Jul
(66) |
Aug
(30) |
Sep
(21) |
Oct
(37) |
Nov
(41) |
Dec
(65) |
2009 |
Jan
(69) |
Feb
(46) |
Mar
(22) |
Apr
(20) |
May
(39) |
Jun
(30) |
Jul
(36) |
Aug
(58) |
Sep
(38) |
Oct
(20) |
Nov
(10) |
Dec
(11) |
2010 |
Jan
(24) |
Feb
(63) |
Mar
(22) |
Apr
(72) |
May
(8) |
Jun
(13) |
Jul
(35) |
Aug
(23) |
Sep
(12) |
Oct
(26) |
Nov
(11) |
Dec
(30) |
2011 |
Jan
(15) |
Feb
(44) |
Mar
(36) |
Apr
(26) |
May
(27) |
Jun
(10) |
Jul
(28) |
Aug
(12) |
Sep
|
Oct
|
Nov
(17) |
Dec
(16) |
2012 |
Jan
(12) |
Feb
(31) |
Mar
(23) |
Apr
(14) |
May
(10) |
Jun
(26) |
Jul
|
Aug
(2) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
(6) |
2013 |
Jan
(4) |
Feb
(5) |
Mar
|
Apr
(4) |
May
(13) |
Jun
(7) |
Jul
(5) |
Aug
(15) |
Sep
(25) |
Oct
(18) |
Nov
(7) |
Dec
(3) |
2014 |
Jan
(1) |
Feb
(5) |
Mar
|
Apr
(3) |
May
(3) |
Jun
(2) |
Jul
(4) |
Aug
(5) |
Sep
|
Oct
(11) |
Nov
|
Dec
(62) |
2015 |
Jan
(8) |
Feb
(3) |
Mar
(15) |
Apr
|
May
|
Jun
(6) |
Jul
|
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(19) |
2016 |
Jan
(2) |
Feb
|
Mar
(2) |
Apr
(4) |
May
(3) |
Jun
(7) |
Jul
(14) |
Aug
(13) |
Sep
(6) |
Oct
(2) |
Nov
(3) |
Dec
|
2017 |
Jan
(6) |
Feb
(14) |
Mar
(2) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(4) |
Nov
(3) |
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
(1) |
Mar
|
Apr
(44) |
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
(1) |
2021 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
2023 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2025 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ian S. <Ian...@et...> - 2004-01-12 17:29:46
|
Has anyone given any more thought to SO -> Webware (esp Fun/FormKit) = integration? Seems like it should be possible to generate a simple SO management = application from an SO model? |
From: Dirk E. <Dir...@Ce...> - 2004-01-12 13:24:07
|
Hi, Mark Mueller asked about the Oracle version of SQLObject a few days ago. The state of affair's is: I moved to a new job (university). I do not use Oracle here. I have not set up any DB related stuff here yet. John Dell'Aquila and myself have a both ported SQLObject to Oracle. Our (untested) first versions where very similar. That's a good sign. :-) The only real issue with SQLObject and Oracle is the slice notation part where you retrieve rows at specific table index positions. Some DBs have LIMIT and OFFSET keywords for this. Oracle has no notion of this. John wrote a kludge version using rownum to retrieve all rows up to the highest index (LIMIT + OFFSET + 1) and then remove the indices smaller than the lowest index (OFFSET) on the python side of things. The version I have somewhere in a tarball is against SQLObject 0.4x. I would be happy to give you a copy. Maybe I'll install Oracle here for test purposes some day. But I can't make any promises... Andy Todd said that he would be happy to test any versions we come up with. John are you still reading this list? Regards, Dirk -- Dirk J. Evers dir...@ce... NRW Graduate School in +49 (0)521/106-3793 Bioinformatics and Genome Research, CeBiTec - Center for Biotechnology University of Bielefeld, D-33594 Bielefeld, Germany |
From: Tracy S. R. <tr...@re...> - 2004-01-09 18:32:38
|
This may be a broader question about relational information design, but I thought I'd put this out anyway. I would like to build an object, say a 'node', that has a number of related 'items' based upon a particular 'context'. In one context, for example, one particular node may 'contain' a certain of items, but contain other items in a different context. Here's how I have it defined in SQLObject. Does anyone see a better way to do this? Or, is there a better way to design associations between two sets of things that depends on the settings of a 3rd thing? class node(SQLObject): name = StringCol(length=32) itemAssociations = MultipleJoin('itemAssociation') def getItems(self, context): return [ia.item for ia in self.itemAssociations if ia.context == context] def getItems_ALT(self, context): # note: 'getItems' is 5-10% faster for small sets of items return [iaq.item for iaq in itemAssociation.select(AND( itemAssociation.q.nodeID==self.id, itemAssociation.q.contextID==context.id))] def associateItem(self, item, context): return itemAssociation.new(node=self, item=item, context=context) class itemAssociation(SQLObject): node = ForeignKey('node') item = ForeignKey('item') context = ForeignKey('context') class item(SQLObject): name = StringCol(length=32) class context(SQLObject): name = StringCol(length=32) For now, I have a 'compile' method in 'node' that takes a context object as its first arg and returns a node and its information/items into a dictionary where its 'items' key is a list of item dictionaries, too. Thanks, --T |
From: Ian B. <ia...@co...> - 2004-01-09 13:24:21
|
On Jan 8, 2004, at 10:33 PM, Javier Ruere wrote: > I was asking because in test_converters.ConvertersTest.test_bool, > PostgreSQL and MySQL are tested but bot SQLite (besides my code not > working :). Also there is special code in BoolCol for the first two DBs > but not for the last one, IIRC. > Has anyone used this type with SQLite successfully? An oversight then. SQLite should work just like MySQL. I thought there were unit tests that would have caught that, but apparently not. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Javier R. <jav...@Ho...> - 2004-01-09 04:14:16
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Ian Bicking wrote: > On Dec 28, 2003, at 1:35 PM, Javier Ruere wrote: > >> I've been away for a while but I see that BoolCol has been added. I >> have been unable to use it with SQLite. After looking the code and the >> tests, I think it is not supported for SQLite. Am I right? It would be >> really useful to me so if I can help with it, count on me. > > It should be working -- at least, I thought it was, but I don't have the > code in front of me at the moment (SF CVS and my laptop are > uncooperative). Non-Boolean-supporting databases (everything but > Postgres) just use integers (1/0). There's other details to how BoolCol > works, but those are database-agnostic. I was asking because in test_converters.ConvertersTest.test_bool, PostgreSQL and MySQL are tested but bot SQLite (besides my code not working :). Also there is special code in BoolCol for the first two DBs but not for the last one, IIRC. Has anyone used this type with SQLite successfully? Javier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQE//i8g8XQC840MeeoRAgeJAKCFoy18b6oGvhjxORpQrPDGsuRPKQCfeefT gdO7gGezukq/kp3CTc8rxzI= =XCsl -----END PGP SIGNATURE----- |
From: Ian B. <ia...@co...> - 2004-01-08 22:37:16
|
On Dec 28, 2003, at 1:35 PM, Javier Ruere wrote: > I've been away for a while but I see that BoolCol has been added. I > have been unable to use it with SQLite. After looking the code and the > tests, I think it is not supported for SQLite. Am I right? It would be > really useful to me so if I can help with it, count on me. It should be working -- at least, I thought it was, but I don't have the code in front of me at the moment (SF CVS and my laptop are uncooperative). Non-Boolean-supporting databases (everything but Postgres) just use integers (1/0). There's other details to how BoolCol works, but those are database-agnostic. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Ian B. <ia...@co...> - 2004-01-08 20:27:15
|
On Dec 27, 2003, at 12:10 PM, David M. Cook wrote: > * Is it possible to do a select distinct? I want to do something like > > Person.select(Address.q.personID=Person.q.id, distinct=1) > > (I guess I could just do: > > people_with_adresses = [p for p in Person.select() if p.addresses] > > Gotta stop thinking "relationally"... No, though perhaps that could be added. It would be a rather small change to SelectResults, and DBConnection.queryForSelect. > * Is there a way to set a unique constraint on multiple columns (with > autogeneration?) Something like: > > class Person(SQLOBject): > > lastName = StringCol() > firstName = StringCol() > UNIQUE('lastName', 'firstName') No, there's no way to do this. In general there's few ways to add things to the CREATE TABLE statement that SQLObject creates. Things like Type=InnoDB, unique constraints, and indexes would all be useful to add. I have some other thoughts about changing the API, and this might fit in somehow. Right now it's all done with separate magic instance variables, like _idName -- there could be a _uniqueCols (like _uniqueCols = [('lastName', 'firstName')]), _tableType, _indexes, etc... but that seems like too much, all these variables need to be separated off into some other kind of description. > * How do I access the dbapi Exception classes? Right now I do an > > import sqlite as dbapi > > to access them, but is there a way do dig down into the connection > object > to get them? They aren't exposed in any way right now. It would be nice if the appropriate exceptions were available as part of the connection. One nuisance is the different ways database adapters use the exceptions. But it would still be helpful -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Mark M. <mar...@ya...> - 2004-01-06 16:05:53
|
Happy New Year To All -- I have several projects that will be starting soon that will need Oracle support - both 8i and 9i. I've seen some discussion about adding Oracle support to SQLObject - which would be great. Can anyone help me find some add-on code that would help me, otherwise I'll have to code sql the old way. Thanks so much!! Mark C. Mueller __________________________________________________ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com |
From: Javier R. <jav...@Ho...> - 2003-12-30 15:45:19
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I've been away for a while but I see that BoolCol has been added. I have been unable to use it with SQLite. After looking the code and the tests, I think it is not supported for SQLite. Am I right? It would be really useful to me so if I can help with it, count on me. Thanks, Javier -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQE/7zBj8XQC840MeeoRApcZAJ9l03/UKlyOnP2n5KjCwhF/wt11nACdGgyS MdDEMa0cIRwud5NFFmBBnH4= =nHHJ -----END PGP SIGNATURE----- |
From: David M. C. <da...@da...> - 2003-12-27 18:13:47
|
* Is it possible to do a select distinct? I want to do something like Person.select(Address.q.personID=Person.q.id, distinct=1) (I guess I could just do: people_with_adresses = [p for p in Person.select() if p.addresses] Gotta stop thinking "relationally"... * Is there a way to set a unique constraint on multiple columns (with autogeneration?) Something like: class Person(SQLOBject): lastName = StringCol() firstName = StringCol() UNIQUE('lastName', 'firstName') * How do I access the dbapi Exception classes? Right now I do an import sqlite as dbapi to access them, but is there a way do dig down into the connection object to get them? Thanks, Dave Cook |
From: Scott R. <sc...@to...> - 2003-12-23 18:45:24
|
Looks like I may be unfairly blaming SQLObject here. I think it's something wierd in the bowels of WebKit's ImportSpy stuff, coupled with a sensitive assert... WebKit does seem to actually re-import sub-imports of __import__ed modules. Not sure why. |
From: Scott R. <sc...@to...> - 2003-12-23 14:56:22
|
I'm converting a mid-size project from webware's middlekit to sqlobject. One problem that I've run out of workarounds for is an import issue, similar to one that was last discussed on the mailing list in September. I'm storing all of my SQLObject classes in a single module called booking. At the top of files that use the classes, I include the line from stuff import * This seems to work fine, except occasionally, when I get File "/sandbox/Main/eventleaf.py", line 1, in ? from stuff import * File "/usr/lib/python2.2/ihooks.py", line 397, in import_module q, tail = self.find_head_package(parent, name) File "/usr/lib/python2.2/ihooks.py", line 433, in find_head_package q = self.import_it(head, qname, parent) File "/usr/lib/python2.2/ihooks.py", line 486, in import_it m = self.loader.load_module(fqname, stuff) File "./WebKit/ImportSpy.py", line 30, in load_module File "/usr/lib/python2.2/ihooks.py", line 270, in load_module m = self.hooks.load_source(name, filename, file) File "/usr/lib/python2.2/ihooks.py", line 168, in load_source return imp.load_source(name, filename, file) File "/sandbox/Main/stuff.py", line 5, in ? class Person(SQLObject): File "/usr/lib/python2.2/site-packages/SQLObject/SQLObject.py", line 151, in __new__ assert not classRegistry.get(registry, {}).has_key(className), "A database object by the name %s has already been created" % repr(className) AssertionError: A database object by the name 'Person' has already been created I'm not changing the definition, just importing the SQLObj classes into a module that is imported by a module that has already imported the SQLObj classes. This seems intermittent, and I have not yet tracked down the situation that makes it happen, but I suspect it may only be happening to modules loaded via this code: res = imp.find_module(req + "leaf") mod = imp.load_module(req + "leaf", res[0], res[1], res[2]) This may be a red herring, but it's starting to smell like the cause. Could someone who understands python and sqlobject internals better than I do help me solve this puzzle? - Scott |
From: alexander s. <al...@an...> - 2003-12-22 19:39:35
|
hello! i think there is a bug in SQLObject attribute value cache: when '_cacheValues' is set, an attribute getter is replaced by value written to data base. if attribute is converted by Validator (fromPython), later access will return DB value for the attribute, and not it's "pythonic" representation. merry Christmas! alex. |
From: Guenther S. <gs...@sy...> - 2003-12-21 15:39:02
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Sunday 21 December 2003 14:09, Guenther Starnberger wrote: hi, > I digged a little bit around in the SQLObject source & found some things > which look like bugs to me (altough i'm not really sure :). Maybe someone > who understands the framework better than me can review these / resolve > them. just noticed another problem: The CacheFactory only creates self.cache if caching is enabled. When=20 'rollback' is called on a Transaction object it does (among other things): subCaches =3D [(sub, sub.allIDs()) for sub in self.cache.allSubCaches()] but the allIDs() method of the CacheFactory just returns self.cache.keys()= =20 without checking if caching is enabled which results in an AttributeError=20 beeing raised. cu /gst =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/5b6OZtF7I/+gjcERAvu/AJ4i/oDsYbmKQkIdpBhgbRpJDsJgpACg1QF4 zIuOzPcRrBpGjtN+fOBGJJ0=3D =3DI234 =2D----END PGP SIGNATURE----- |
From: Guenther S. <gs...@sy...> - 2003-12-21 13:10:55
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I digged a little bit around in the SQLObject source & found some things wh= ich=20 look like bugs to me (altough i'm not really sure :). Maybe someone who=20 understands the framework better than me can review these / resolve them. =2D --- DBConnection.py / PostgresConnection / __init__: =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- def __init__(self, dsn=3DNone, host=3DNone, db=3DNone, ___ user=3DNone, passwd=3DNone, autoCommit=3D1, ___ usePygresql=3DFalse, ___ **kw): [...] self.autoCommit =3D autoCommit [...] DBAPI.__init__(self, **kw) =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- When you run PostgresConnection with the argument 'autoCommit =3D 0' in the= =20 constructor it sets self.autoCommit to 0 too. But afterwards it calls DBAPI.__init__ only with **kw, but not with the oth= er=20 named arguments. DBAPI.__init__ calls DBConnection.__init__ which doesn't g= et=20 the autoCommit argument (because it isn't stored in **kw) and which default= s=20 to 'autoCommit=3DTrue'. Therefore autoCommit is always True, no matter which value is passed to the= =20 PostgresConnection Constructor. =2D --- DBConnection.py / class DBAPI / releaseConnection: =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- elif self.autoCommit: ___ if self.debug: _______ self.printDebug(conn, 'auto', 'COMMIT') ___ conn.commit() =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- when autoCommit is active the PgSQL adapter throws an 'Commit failed -=20 autocommit is on.' exception when commit() is called. Shouldn't this be a 'elif not self.autoCommit' instead (without an else=20 statement afterwards)? Imo the connection only needs the 'COMMIT' if it isn= 't=20 set to autoCommit. There is another similiar Problem with the 'pool' argument which is added b= y=20 PostgresConnection to **kw, but which isn't expected by DBConnection. (I=20 posted bug #859999 some time ago on the SourceForge project page). =2D --- btw, I have used my PgSQL adapter (i posted a patch some time ago) now for= =20 some time without any major problems. As (AFAIK) the only Python PostgreSQL Library PgSQL supports Unicode (my=20 adapter should support this, though i have to admit that i haven't really=20 tested it yet). As PgSQL Code is in its own class (inherited from=20 PostgresConnection), it shouldn't affect any other code. If there's a chance of getting PgSQL Support into SQLObject i'll repost my= =20 patch to it. cu /gst =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/5ZumZtF7I/+gjcERAl/rAJ42A0m6XKIHqxi4WHaXuxwVPIIT2wCghx6Q 9Iglk+dsGtB5Usn1giTfUsw=3D =3Dmp5M =2D----END PGP SIGNATURE----- |
From: Guenther S. <gs...@sy...> - 2003-12-20 15:07:19
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 19 December 2003 22:05, Ian Bicking wrote: hi, > Each new Account is going to have a reference to the connection, so > that's to be expected. Hmm... and the accounts won't be deleted > because they are cached. That's the problem, then. Maybe the > transaction simply needs to clear its cache on a commit/rollback (well, > you can't really clear the cache, but you can make all the objects > GCable). hmm.. shouldn't objects in the cache automatically expire 'faster' when i = set=20 the cullFrequency to a lower value? i tried setting the cullFrequency to 5= =20 and running gc.collect() after every iteration, but the refcount to the=20 connection still stays the same (resp. +1 at every iteration). on the other hand when i disable caching by passing "cache =3D False" to th= e=20 connection & run the gc it works fine (the refcount to 'conn' doesn't=20 increase). cu /gst =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/5GWeZtF7I/+gjcERAva+AJ9H/M2TjDu4GeP+ypEreDrud/zOVQCgiNdp hZ13/zMOlWTM+0/bkJzXYHA=3D =3D3rEe =2D----END PGP SIGNATURE----- |
From: Ian B. <ia...@co...> - 2003-12-19 21:04:59
|
> using the following while block: > > while 1: > ___ b = Account.new(name = "FOO" + str(time.time()), password = "bar", > connection = conn) > ___ print sys.getrefcount(conn) > ___ del(b) > > shows an increasing refcount of conn with every iteration. maybe the > leak > is somewhere in the sqlobject class? Each new Account is going to have a reference to the connection, so that's to be expected. Hmm... and the accounts won't be deleted because they are cached. That's the problem, then. Maybe the transaction simply needs to clear its cache on a commit/rollback (well, you can't really clear the cache, but you can make all the objects GCable). -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Guenther S. <gs...@sy...> - 2003-12-19 20:46:22
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thursday 18 December 2003 00:50, you wrote: hi, > Hmm.. that shouldn't happen. Though looking at the code, I don't do a > whole lot to return connections. The transaction should get garbage > collected, and __del__ releases the connection, but I can imagine > there'd be lots of reasons a transaction wouldn't get collected (though > in this case it looks like it should be). > > Probably on commit()/rollback() the transaction should become invalid, > and the connection should be returned. Or maybe you could run > trans.begin() to revalidate it (at which point it'd grab another > connection). using the following while block: while 1: ___ b = Account.new(name = "FOO" + str(time.time()), password = "bar", connection = conn) ___ print sys.getrefcount(conn) ___ del(b) shows an increasing refcount of conn with every iteration. maybe the leak is somewhere in the sqlobject class? cu /gst -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/42OUZtF7I/+gjcERAqPsAKCuapSeoG3udyvRrytIRu67bqxRzACgzO5F FblDKu3mUSZvZ0RNtfO57Yo= =IX1s -----END PGP SIGNATURE----- |
From: J-P L. <sql...@si...> - 2003-12-18 15:31:33
|
<mailto:sql...@li...>This is a patch against v0.5.1. I'm using bytea field types in my tables and this patch makes life easier. In my SQLObject classes, I do: def _set_data(self, val): self._SO_set_data(psycopg.Binary(val)) Seems to work with some preliminary testing. Index: SQLObject/Converters.py =================================================================== RCS file: /usr/local/cvs/depot/sqlobject/SQLObject/Converters.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -5 -r1.1 -r1.2 --- SQLObject/Converters.py 17 Nov 2003 22:36:02 -0000 1.1 +++ SQLObject/Converters.py 18 Dec 2003 15:03:27 -0000 1.2 @@ -135,10 +135,19 @@ return "(%s)" % ", ".join([sqlrepr(v, db) for v in value]) registerConverter(type(()), SequenceConverter) registerConverter(type([]), SequenceConverter) +try: + import psycopg +except ImportError: pass +else: + def PsycopgBinaryConverter(value, db): + return str(value) + + registerConverter(type(psycopg.Binary('')), PsycopgBinaryConverter) + if hasattr(time, 'struct_time'): def StructTimeConverter(value, db): return time.strftime("'%Y-%m-%d %H:%M:%S'", value) registerConverter(time.struct_time, StructTimeConverter) |
From: Ian B. <ia...@co...> - 2003-12-17 23:50:05
|
On Dec 17, 2003, at 3:24 PM, Guenther Starnberger wrote: > from SQLObject import * > import time > > class Account(SQLObject): > ___ name = StringCol(alternateID = True) > ___ password = StringCol() > > conn = PostgresConnection('user=zope dbname=WebspaceNG', autoCommit = > False) > > while 1: > ___ trans = conn.transaction() > ___ b = Account.new(name = "FOO" + str(time.time()), password = "bar", > connection = trans) > ___ trans.commit() > ___ raw_input() > - -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- > > if you run this code, with every iteration an additional connection > gets > opened to the postgresql server (until the max. connection limit is > reached & > postgresql refuses new connections). Hmm.. that shouldn't happen. Though looking at the code, I don't do a whole lot to return connections. The transaction should get garbage collected, and __del__ releases the connection, but I can imagine there'd be lots of reasons a transaction wouldn't get collected (though in this case it looks like it should be). Probably on commit()/rollback() the transaction should become invalid, and the connection should be returned. Or maybe you could run trans.begin() to revalidate it (at which point it'd grab another connection). -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Guenther S. <gs...@sy...> - 2003-12-17 21:24:19
|
=2D----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 hi, i noticed that when using sqlobject together with zope after some time more and more connections are open to my postgresql server. first i thought that it was a zope bug (i am binding sqlobject transactions= to zope transactions and assumed, that the transaction objects were referenced from somewhere in the ZODB), but now it seems that it is a bug in sqlobject. =20 =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- from SQLObject import * import time class Account(SQLObject): ___ name =3D StringCol(alternateID =3D True) ___ password =3D StringCol() = =20 conn =3D PostgresConnection('user=3Dzope dbname=3DWebspaceNG', autoCommit = =3D False) = =20 while 1: ___ trans =3D conn.transaction() ___ b =3D Account.new(name =3D "FOO" + str(time.time()), password =3D "bar"= , connection =3D trans) ___ trans.commit() ___ raw_input() =2D -------- 8< -------- 8< -------- 8< -------- 8< -------- 8< -------- if you run this code, with every iteration an additional connection gets opened to the postgresql server (until the max. connection limit is reached= & postgresql refuses new connections). cu /gst =2D----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/4Ml1ZtF7I/+gjcERAkT8AJ0bvPL8+SoglxVTWbVrAdPmO/qRUACZAc9y lAIFFBN8XaQRxA0btc4E8iM=3D =3DXoeD =2D----END PGP SIGNATURE----- |
From: Guenther S. <gs...@sy...> - 2003-12-16 07:14:05
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 16 December 2003 01:28, Ian Bicking wrote: Hi, > def new(cls, **kw): > yada yada > return super(MyClass, cls).new(**kw) > new = classmethod(new0 Yop - thanks Ian & Edmund. In this way it works. :) cu /gst -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.3 (GNU/Linux) iD8DBQE/3rC6ZtF7I/+gjcERAv6gAKDGheG83UiTzorkNjT2hNggaK7kqwCgvDR8 C+n+l+MfQIj3WgSTrx6LCz0= =vCMh -----END PGP SIGNATURE----- |
From: Ian B. <ia...@co...> - 2003-12-16 05:41:16
|
On Dec 13, 2003, at 11:04 PM, Ken Kinder wrote: > Upon exploring the source code, I think I have isolated the problem. > Your > DBAPI.runWithConnection method from SQLObject/DBConnection.py has the > following definition: Good catch. Applied to CVS. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Edmund L. <el...@in...> - 2003-12-16 02:52:44
|
On Dec 16, 2003, at 10:33, Edmund Lian wrote: > I started that thread. Which version of Python are you using? Turns > out that there is a bug in the classmethod code that causes > inheritance problems in Python < 2.2.3 (I think, can't quite remember > now). That was one problem. The bug was but 535444, where super() was broken for classmethods in Python < 2.2.1 ...Edmund. |
From: Edmund L. <el...@in...> - 2003-12-16 02:33:28
|
On Dec 15, 2003, at 18:26, Guenther Starnberger wrote: > some time ago there was a thread on this mailinglist, about overiding > the > new() method in classes inherited from SQLObject. > (http://thread.gmane.org/gmane.comp.python.sqlobject/906) > > according to a posting in this thread it is possible to call the > 'original' > SQLObject new() method by: 'SQLObject.new(cls, **kw)'. > > but somehow this doesn't work for me :/ > > class Account(SQLObject): > __name = StringCol(alternateID = True) > __password = StringCol() > > __def new(cls, **kw): > ____print "FOO" > ____SQLObject.new(cls, **kw) > > __new = classmethod(new) I started that thread. Which version of Python are you using? Turns out that there is a bug in the classmethod code that causes inheritance problems in Python < 2.2.3 (I think, can't quite remember now). That was one problem. I override new as follows: def new(cls, **kw): """ Overrides class method .new() to automatically add mandatory sections to request object """ obj = super(Request, cls).new(**kw) return obj new = classmethod(new) ...Edmund. |