sqlobject-discuss Mailing List for SQLObject (Page 404)
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 B. <ia...@co...> - 2003-10-27 21:25:19
|
On Monday, October 27, 2003, at 02:55 PM, Sidnei da Silva wrote: > | SQLObject.expire() expires the *instance's* cache of its column > values. > > Oh, I didn't notice there was an instance cache as well. > > | When you create an instance, it gets its column values from the > | database immediately. When a transaction is rolled back we expire > all > | the effected instances' caches so that they don't contain stale > | information from a rolled-back transaction. (There perhaps should be > | other circumstances where we automatically expire instances, but I > | haven't thought that through). > | > | The per-connection cache is a different issue. > | > | I'm not sure what SQLObject should do for an ObjectModified message. > | What does this message mean? There's also the issue of non-column > | instance variables (which you might manually add to a SQLObject > | subclass) and rolling those values back... that might be related, or > | maybe you are avoiding that issue entirely for the moment. > > I'm starting to get a feeling that the issue is deeper than I thought > :) > > Last time I checked there was a cache for attributes, so when you > changed an attribute it wasn't immediately updated on the database, > -- or it was updated immediately on the database, but objects could > still fetch old values from the cache -- I'm not exactly sure what was > it. I think there's maybe some confusion about the different objects. First, caching happens per-connection. Which means each transaction has its own cache, if you are using transactions. If you create an object by a certain ID in a transaction, any attempt to get that object by that ID from the same transaction will give you back the same object you got before, guaranteed. But in a different transaction you will get a different object, since the two transactions are isolated. It just occurred to me there's some sloppiness when it comes to committing or rolling back a transaction. The objects stick around, but once you've finalized the transaction I don't know what use they are. Those instances should actually be invalid. Unless you assume that by committing or rolling back a transaction, you are implicitly restarting the transaction and can keep using it. Anyway, I don't think this applies to this circumstance, but it should be worked out. So -- attributes changes immediately update the database. They also update the internal cache of that column. Other instances that are in other transactions are not effected. They aren't effected when you commit the transaction. It seems like at some point they should be effected (expired, perhaps), but I'm not sure where. > I'm not using any non-column instance variable (or at least, no > meaningful ones). > > An ObjectModified message would be generated anytime an object was > modified, like when setting a column instance variable. This would > trigger clearing the cache for that instance and maybe mark the > instance as modified. The intent IMHO, is to avoid reading from the > database as much as possible, probably having all the column > variables in cache, and renewing all of them in a single step when the > cache gets cleared. I haven't really looked that deeply into the > caching implementation. SQLObject should already handle this, at least for an individual instance. It knows when you change an attribute and updates its own cache. I imagine ObjectModified is meant for something like ZODB, where persistence is added more transparently to an instance (the expense being that something must be watching the instance and telling it when it's been changed). I think SQLObject can ignore that message, as instances are self-aware. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-10-27 21:06:50
|
| So for some reason an exception propagated out of SQLObject.new won't | cause the TransactionManager to roll back the transaction, even though | exceptions anywhere else do work. How odd. What does SQLObject's | connection to TransactionManager look like? Very odd indeed. I am about to dive into pdb and see what comes out. | Does it work any differently if you successfully create (or interact | with) a SQLObject instance, then get an exception in SQLObject.new? | (As opposed to an exception in SQLObject.new being the first query for | the transaction) Thats a good question. I'll test and report back. -- Sidnei da Silva <si...@aw...> dreamcatching :: making your dreams come true http://awkly.org I am NOMAD! |
From: Ian B. <ia...@co...> - 2003-10-27 21:05:48
|
On Monday, October 27, 2003, at 02:46 PM, Sidnei da Silva wrote: > | Rolling back in that circumstance is way too aggressive. It should > be > | possible to catch the exception and handle it within the transaction. > > That's what I thought, but it doesn't seem to be getting far enough to > call rollback() from what I can see, which is really strange. The > current situation is that I have the SQLObject registered with Zope's > TransactionManager and when there's an exception, Zope aborts the > transaction, calling SQLObject's rollback() method. This works fine in > all cases, *except* when the exception happens in SQLObject.new (or so > it seems). > > | Do you have an idea what "idle in transaction" means, and what's > | causing it? Are we talking about database-generated exceptions (like > | IntegrityError), or Python-generated (ValueError or something)? Or > | either? > > It is waiting either for a rollback or a commit (eg: its a transaction > in progress). The exception is TypeError, generated inside > SQLObject.new(). When I call the rollback() there before raising the > exception, it works just fine. So for some reason an exception propagated out of SQLObject.new won't cause the TransactionManager to roll back the transaction, even though exceptions anywhere else do work. How odd. What does SQLObject's connection to TransactionManager look like? Does it work any differently if you successfully create (or interact with) a SQLObject instance, then get an exception in SQLObject.new? (As opposed to an exception in SQLObject.new being the first query for the transaction) -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-10-27 21:03:04
|
| SQLObject.expire() expires the *instance's* cache of its column values. Oh, I didn't notice there was an instance cache as well. | When you create an instance, it gets its column values from the | database immediately. When a transaction is rolled back we expire all | the effected instances' caches so that they don't contain stale | information from a rolled-back transaction. (There perhaps should be | other circumstances where we automatically expire instances, but I | haven't thought that through). | | The per-connection cache is a different issue. | | I'm not sure what SQLObject should do for an ObjectModified message. | What does this message mean? There's also the issue of non-column | instance variables (which you might manually add to a SQLObject | subclass) and rolling those values back... that might be related, or | maybe you are avoiding that issue entirely for the moment. I'm starting to get a feeling that the issue is deeper than I thought :) Last time I checked there was a cache for attributes, so when you changed an attribute it wasn't immediately updated on the database, -- or it was updated immediately on the database, but objects could still fetch old values from the cache -- I'm not exactly sure what was it. I'm not using any non-column instance variable (or at least, no meaningful ones). An ObjectModified message would be generated anytime an object was modified, like when setting a column instance variable. This would trigger clearing the cache for that instance and maybe mark the instance as modified. The intent IMHO, is to avoid reading from the database as much as possible, probably having all the column variables in cache, and renewing all of them in a single step when the cache gets cleared. I haven't really looked that deeply into the caching implementation. []'s -- Sidnei da Silva <si...@aw...> dreamcatching :: making your dreams come true http://awkly.org The Macintosh is Xerox technology at its best. |
From: Sidnei da S. <si...@aw...> - 2003-10-27 20:58:07
|
| Rolling back in that circumstance is way too aggressive. It should be | possible to catch the exception and handle it within the transaction. That's what I thought, but it doesn't seem to be getting far enough to call rollback() from what I can see, which is really strange. The current situation is that I have the SQLObject registered with Zope's TransactionManager and when there's an exception, Zope aborts the transaction, calling SQLObject's rollback() method. This works fine in all cases, *except* when the exception happens in SQLObject.new (or so it seems). | Do you have an idea what "idle in transaction" means, and what's | causing it? Are we talking about database-generated exceptions (like | IntegrityError), or Python-generated (ValueError or something)? Or | either? It is waiting either for a rollback or a commit (eg: its a transaction in progress). The exception is TypeError, generated inside SQLObject.new(). When I call the rollback() there before raising the exception, it works just fine. []'s -- Sidnei da Silva <si...@aw...> dreamcatching :: making your dreams come true http://awkly.org System going down in 5 minutes. |
From: Ian B. <ia...@co...> - 2003-10-27 20:44:38
|
On Monday, October 27, 2003, at 02:03 PM, Sidnei da Silva wrote: > Howdy folks, > > I'm experiencing the following problem: When an object is created, if > an exception happens inside new(), for example, a parameter which has > no default is missing, postgres gets hung on 'idle in transaction' > state. To fix it I made the following two small changes, though I'm > not sure that it will do the right thing in all cases. Any better > suggestion? Rolling back in that circumstance is way too aggressive. It should be possible to catch the exception and handle it within the transaction. Do you have an idea what "idle in transaction" means, and what's causing it? Are we talking about database-generated exceptions (like IntegrityError), or Python-generated (ValueError or something)? Or either? -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Ian B. <ia...@co...> - 2003-10-27 20:43:34
|
On Monday, October 27, 2003, at 02:12 PM, Sidnei da Silva wrote: > Howdy again, > > I am in the process on getting the Zope3+SQLObject integration to the > next level, which is optimization. I haven't started profiling yet, > but one of the things that I would like to try is to enable cache on > SQLObject (I disabled it since the start because it was getting too > much in the way) and hook with the event system in Zope 3 to process > cache invalidation when an ObjectModified message comes > through. However I am not sure about the way the SQLObject.expired() > method is implemented. It seems that it is doing a bit more than > expiring the cache, it is also marking the object as expired and > removing something from the instance which I'm not sure what it > is. The way I see it, I should probaly call expired() which would > mark the object as expired and clear the cache for that object. On the > first attribute access after that, SQLObject would find the cache is > empty, fetch the live values from database and remove the expired mark > from the object. Maybe a revalidate() method on SQLObject could do it, > to make it simpler. Am I close? SQLObject.expire() expires the *instance's* cache of its column values. When you create an instance, it gets its column values from the database immediately. When a transaction is rolled back we expire all the effected instances' caches so that they don't contain stale information from a rolled-back transaction. (There perhaps should be other circumstances where we automatically expire instances, but I haven't thought that through). The per-connection cache is a different issue. I'm not sure what SQLObject should do for an ObjectModified message. What does this message mean? There's also the issue of non-column instance variables (which you might manually add to a SQLObject subclass) and rolling those values back... that might be related, or maybe you are avoiding that issue entirely for the moment. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Sidnei da S. <si...@aw...> - 2003-10-27 20:22:01
|
Howdy again, I am in the process on getting the Zope3+SQLObject integration to the next level, which is optimization. I haven't started profiling yet, but one of the things that I would like to try is to enable cache on SQLObject (I disabled it since the start because it was getting too much in the way) and hook with the event system in Zope 3 to process cache invalidation when an ObjectModified message comes through. However I am not sure about the way the SQLObject.expired() method is implemented. It seems that it is doing a bit more than expiring the cache, it is also marking the object as expired and removing something from the instance which I'm not sure what it is. The way I see it, I should probaly call expired() which would mark the object as expired and clear the cache for that object. On the first attribute access after that, SQLObject would find the cache is empty, fetch the live values from database and remove the expired mark from the object. Maybe a revalidate() method on SQLObject could do it, to make it simpler. Am I close? []'s -- Sidnei da Silva <si...@aw...> dreamcatching :: making your dreams come true http://awkly.org When Dexter's on the Internet, can Hell be far behind?" |
From: Sidnei da S. <si...@aw...> - 2003-10-27 20:11:39
|
Howdy folks, I'm experiencing the following problem: When an object is created, if an exception happens inside new(), for example, a parameter which has no default is missing, postgres gets hung on 'idle in transaction' state. To fix it I made the following two small changes, though I'm not sure that it will do the right thing in all cases. Any better suggestion? Index: SQLObject.py =================================================================== RCS file: /cvsroot/sqlobject/SQLObject/SQLObject/SQLObject.py,v retrieving revision 1.61 diff -u -r1.61 SQLObject.py --- SQLObject.py 24 Oct 2003 19:18:52 -0000 1.61 +++ SQLObject.py 27 Oct 2003 20:04:58 -0000 @@ -852,6 +852,7 @@ # If we don't get it, it's an error: if default is NoDefault: + inst._connection.transaction().rollback() raise TypeError, "%s did not get expected keyword argument %s" % (cls.__name__, repr(column.name)) # Otherwise we put it in as though they did pass # that keyword: @@ -876,6 +877,7 @@ try: getattr(cls, name) except AttributeError: + inst._connection.transaction().rollback() raise TypeError, "%s.new() got an unexpected keyword argument %s" % (cls.__name__, name) setattr(inst, name, value) -- Sidnei da Silva <si...@aw...> dreamcatching :: making your dreams come true http://awkly.org Real Users are afraid they'll break the machine -- but they're never afraid to break your face. |
From: Frank B. <fb...@fo...> - 2003-10-27 16:11:00
|
Hallo, Frank Barknecht hat gesagt: // Frank Barknecht wrote: > Hallo, > Ian Bicking hat gesagt: // Ian Bicking wrote: > > > On Sunday, October 26, 2003, at 04:48 PM, Frank Barknecht wrote: > > > {'title': ['rock'], 'format': ['cd'], 'artist': ['strokes', 'the']} > > > > query = None > > for colName, ops in above_dict.items(): > > for op in ops: > > subquery = LIKE(getattr(Product.q, colName), op) > > if query: > > query = AND(query, subquery) > > else: > > query = subquery > > > > > > It might be nice if Product.q allowed dictionary access too. And if > > AND(anything, None) return anything. But this will work too. > > I *knew* it had to be something basic (or built-in). A thousand thanks > for opening my eyes. So, and to give something back, here's my QueryBuilder class that's intended to be used with Webware's extraPathInfo and automates searching via the extra-URL: ### snip ### from SQLObject import * class QueryBuilder(object): def __init__(self, table, url=""): self.__url = url self.__sql = None self.__conds = {} self._table = table self._cols = self._table._SO_columnDict.keys() id url: self.parse() def set_url(self, url): self.__url = url self.parse() def get_sql(self): query = None for colName, ops in self.__conds.items(): for op in ops: subquery = LIKE(getattr(self._table.q, colName), "%%%s%%" % op) if colName == "id": subquery = self._table.q.id == op if query: query = AND(query, subquery) else: query = subquery return query def parse(self): cols = self._cols cols.append("id") u = self.__url.split("/") l = len(u) i = 0 conds = {} last = None while i < l: if last and u[i]: conds[last] = conds.get(last, []) conds[last].append(u[i]) last = None elif u[i] in cols: last = u[i] i += 1 self.__conds = conds url = property(None, set_url, None, "URL property, write only") sql = property(get_sql, None, None, "SQL property, read only") ### snip ### Not that elegant, but working fine for "flat" databases. It's used like this: # Product is an SQLObject with attrs: name, title, description,... q = QueryBuilder(Product) q.url = "name/potter/name/harry/description/book/foo/bar/" print q.sql print "Number of results: %d " % len (table.select(q.sql)) for n in list(table.select(q.sql)[0:10]): print "%s: %s" % (n.name, n.title) ciao -- Frank Barknecht _ ______footils.org__ |
From: Mike E. <mi...@mi...> - 2003-10-27 07:26:48
|
Hi I am just starting out with SQLObject. I have put together a few small = test scripts successfully. Now has come the time to get a little = cleverer in anticipation of incorporating it into my project. I am writing an application using wxPython. To keep things tidy in my = own mind I am using multiple files to define the classes and importing = them into the main file. When I put my SQLObject class into another file (from a previously = working script) I get the following error: File "C:\Python23\Lib\site-packages\SQLObject\SQLObject.py", line 394, = in __new__ cache =3D cls._connection.cache AttributeError: 'NoneType' object has no attribute 'cache' While solving this problem won't get me all the way to where I want to = be, it'll be a start. Thanks in advance Mike |
From: Frank B. <fb...@fo...> - 2003-10-27 00:01:48
|
Hallo, Ian Bicking hat gesagt: // Ian Bicking wrote: > On Sunday, October 26, 2003, at 04:48 PM, Frank Barknecht wrote: > > {'title': ['rock'], 'format': ['cd'], 'artist': ['strokes', 'the']} > > query = None > for colName, ops in above_dict.items(): > for op in ops: > subquery = LIKE(getattr(Product.q, colName), op) > if query: > query = AND(query, subquery) > else: > query = subquery > > > It might be nice if Product.q allowed dictionary access too. And if > AND(anything, None) return anything. But this will work too. I *knew* it had to be something basic (or built-in). A thousand thanks for opening my eyes. ciao -- Frank Barknecht _ ______footils.org__ |
From: Ian B. <ia...@co...> - 2003-10-26 23:14:28
|
On Sunday, October 26, 2003, at 04:48 PM, Frank Barknecht wrote: > I could need a little help with understanding how to build > SQLObject selections dynamically. > > So far, I have a dictionary that describes the criteria to search the > DB. Keys are my Columns, values are lists of search words. Like this: > > {'title': ['rock'], 'format': ['cd'], 'artist': ['strokes', 'the']} query = None for colName, ops in above_dict.items(): for op in ops: subquery = LIKE(getattr(Product.q, colName), op) if query: query = AND(query, subquery) else: query = subquery It might be nice if Product.q allowed dictionary access too. And if AND(anything, None) return anything. But this will work too. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Frank B. <fb...@fo...> - 2003-10-26 22:52:49
|
Hi all, I could need a little help with understanding how to build SQLObject selections dynamically. So far, I have a dictionary that describes the criteria to search the DB. Keys are my Columns, values are lists of search words. Like this: {'title': ['rock'], 'format': ['cd'], 'artist': ['strokes', 'the']} That should become like this: results = Product.select( AND( LIKE(Product.q.title, "rock"), LIKE(Product.q.format, "cd"), LIKE(Product.q.artist, "strokes"), LIKE(Product.q.artist, "the") )) I know I could do something like eval(""" LIKE(Product.q.%s, "%s" """, (key, value)) but this is so ugly, it just feels very wrong. I also could build the SQL directly, but this feels still a little bit wrong, although might be okay. My main problem is: How do I do the mapping between attribute names (like the keys in my dict) and the attributes themselves (like Product.q.title or Product.title)? Is there some introspection available? I found the _SO_columnDict but this didn't help much yet. But then maybe it's just late. Anyway I'd love to hear some opinions on this. ciao -- Frank Barknecht _ ______footils.org__ |
From: Guenther S. <gs...@sy...> - 2003-10-25 09:54:20
|
On Fri, 2003-10-24 at 22:28, Guenther Starnberger wrote: hi, > I've updated the DBConnection.PostgresConnection class to support the > PgSQL Adapter because i want to use Unicode strings (and it seems that > at least psycopg doesn't support Unicode). The patch is attached to this > mail. i've updated the patch to support unicode & moved the code into its own class (PgSQLConnection). cu /gst |
From: Guenther S. <gs...@sy...> - 2003-10-24 20:29:47
|
Hi all, I've updated the DBConnection.PostgresConnection class to support the PgSQL Adapter because i want to use Unicode strings (and it seems that at least psycopg doesn't support Unicode). The patch is attached to this mail. Using PgSQL is possible by adding the argument 'usePgSQL=True' to the constructor. I haven't really tested the code yet (just some INSERT & SELECT queries), so it is likely that there are still some problems. cu /gst |
From: John B. <jb...@te...> - 2003-10-24 18:10:39
|
Hello, Any ideas how I can store unicode characters in a MySQL database through SQLObject? Ie, how can I store the "pound" sign... John -- John Baker, Senior Developer, TEAM. http://www.teamenergy.com Views expressed in this mail are my own. |
From: Ian B. <ia...@co...> - 2003-10-22 17:01:53
|
This is covered in the FAQ: http://sqlobject.org/docs/FAQ.html#how-does-inheritance-work On Wednesday, October 22, 2003, at 05:21 AM, John Baker wrote: > Hello, > > I come from the world of Java and 'Objectmatter' > (www.objectmatter.com). I'm > rather fond of Objectmatter, and it supports superset mappings rather > nicely. > > If I wanted to model the following using SQLObject, is it possible? > > class Area (SQLObject): > address = StringCol() > > class House (Area): > someField = StringCol() > > class Office (Area): > department = IntCol() > > So I had tables Area, House and Office created, where House and Office > had a > foreign key to a row in Area. Therefore inserting an Office would mean > I had > one row in Area and one row in Office inserted. This then means I can > have a > collection of Areas, and not care whether they are a House or an > Office. > > I've found SQLObject to create a table for House and Office using the > above > example, but put the address field in both tables and not create an > Area > table. > > Thanks > > > John > > -- > John Baker, Senior Developer, TEAM. > http://www.teamenergy.com > Views expressed in this mail are my own. > > > ------------------------------------------------------- > This SF.net email is sponsored by OSDN developer relations > Here's your chance to show off your extensive product knowledge > We want to know what you know. Tell us and you have a chance to win > $100 > http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: John B. <jb...@te...> - 2003-10-22 11:30:15
|
Hello, I come from the world of Java and 'Objectmatter' (www.objectmatter.com). I'm rather fond of Objectmatter, and it supports superset mappings rather nicely. If I wanted to model the following using SQLObject, is it possible? class Area (SQLObject): address = StringCol() class House (Area): someField = StringCol() class Office (Area): department = IntCol() So I had tables Area, House and Office created, where House and Office had a foreign key to a row in Area. Therefore inserting an Office would mean I had one row in Area and one row in Office inserted. This then means I can have a collection of Areas, and not care whether they are a House or an Office. I've found SQLObject to create a table for House and Office using the above example, but put the address field in both tables and not create an Area table. Thanks John -- John Baker, Senior Developer, TEAM. http://www.teamenergy.com Views expressed in this mail are my own. |
From: Brad B. <br...@bb...> - 2003-10-15 20:09:47
|
(Sorry for the delayed response. I've been switching back and forth between a Zope app and this SQLObject/Webware-driven credit card processing system.) On Tuesday, October 14, 2003, at 04:58 PM, Ian Bicking wrote: > On Tuesday, October 14, 2003, at 03:11 PM, Brad Bollenbach wrote: >> Hi, >> >> So, in running off the bleeding edge version of CVS, the >> two-FK's-in-A-pointing-to-the-same-B problem went away, but >> (literally) all my tests broke. :/ > > >> The culprit is illustrated by the following snippet: [snip snippet] > Hmm... DBConnection.py:211 should be "q = sqlrepr(select.clause, > self.dbName)"... I'll need to do more tests before I'm sure that this > fixes it properly, though. I put this change in my copy (of the most recent CVS) and the five tests in my app's test suite that exercised this particular bug now pass. Thanks, -- Brad Bollenbach BBnet.ca |
From: Ian B. <ia...@co...> - 2003-10-14 21:00:26
|
On Tuesday, October 14, 2003, at 03:11 PM, Brad Bollenbach wrote: > Hi, > > So, in running off the bleeding edge version of CVS, the > two-FK's-in-A-pointing-to-the-same-B problem went away, but > (literally) all my tests broke. :/ > > The culprit is illustrated by the following snippet: > > bradb@xdev200:~/1ave/merchant/lib/tests$ python > Python 2.2.3 (#1, Jun 13 2003, 18:46:44) > [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> from SQLObject import * > >>> __connection__ = PostgresConnection( > ... host = 'localhost', > ... db = 'foobar', > ... user = 'foobar', > ... passwd = 'foobar' > ... ) > >>> class FooBar(SQLObject): > ... foo = StringCol() > ... > >>> FooBar.createTable() > >>> f = FooBar.new(foo = 'test') > >>> FooBar.select(FooBar.q.foo == 'test') > <SQLObject.SQLObject.SelectResults object at 0x82adb6c> > >>> list(FooBar.select(FooBar.q.foo == 'test')) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", > line 165, in _iterSelect > query = self.queryForSelect(select) > File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", > line 207, in queryForSelect > return self._addWhereClause(select, q) > File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", > line 211, in _addWhereClause > q = str(select.clause) > File "/home/bradb/src/Python/modules/SQLObject/SQLBuilder.py", line > 157, in __str__ > return self.__sqlrepr__(None) > File "/home/bradb/src/Python/modules/SQLObject/SQLBuilder.py", line > 221, in __sqlrepr__ > return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, > sqlrepr(self.expr2, db)) > File "/home/bradb/src/Python/modules/SQLObject/Converters.py", line > 170, in sqlrepr > return converter(obj, db) > File "/home/bradb/src/Python/modules/SQLObject/Converters.py", line > 92, in StringLikeConverter > assert 0, "Database %s unknown" % db > AssertionError: Database None unknown > > FWIW, I did the same test as above with an IntCol and it worked fine. Hmm... DBConnection.py:211 should be "q = sqlrepr(select.clause, self.dbName)"... I'll need to do more tests before I'm sure that this fixes it properly, though. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Brad B. <br...@bb...> - 2003-10-14 20:11:29
|
Hi, So, in running off the bleeding edge version of CVS, the two-FK's-in-A-pointing-to-the-same-B problem went away, but (literally) all my tests broke. :/ The culprit is illustrated by the following snippet: bradb@xdev200:~/1ave/merchant/lib/tests$ python Python 2.2.3 (#1, Jun 13 2003, 18:46:44) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from SQLObject import * >>> __connection__ = PostgresConnection( ... host = 'localhost', ... db = 'foobar', ... user = 'foobar', ... passwd = 'foobar' ... ) >>> class FooBar(SQLObject): ... foo = StringCol() ... >>> FooBar.createTable() >>> f = FooBar.new(foo = 'test') >>> FooBar.select(FooBar.q.foo == 'test') <SQLObject.SQLObject.SelectResults object at 0x82adb6c> >>> list(FooBar.select(FooBar.q.foo == 'test')) Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", line 165, in _iterSelect query = self.queryForSelect(select) File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", line 207, in queryForSelect return self._addWhereClause(select, q) File "/home/bradb/src/Python/modules/SQLObject/DBConnection.py", line 211, in _addWhereClause q = str(select.clause) File "/home/bradb/src/Python/modules/SQLObject/SQLBuilder.py", line 157, in __str__ return self.__sqlrepr__(None) File "/home/bradb/src/Python/modules/SQLObject/SQLBuilder.py", line 221, in __sqlrepr__ return "(%s %s %s)" % (sqlrepr(self.expr1, db), self.op, sqlrepr(self.expr2, db)) File "/home/bradb/src/Python/modules/SQLObject/Converters.py", line 170, in sqlrepr return converter(obj, db) File "/home/bradb/src/Python/modules/SQLObject/Converters.py", line 92, in StringLikeConverter assert 0, "Database %s unknown" % db AssertionError: Database None unknown FWIW, I did the same test as above with an IntCol and it worked fine. -- Brad Bollenbach BBnet.ca |
From: Brad B. <br...@bb...> - 2003-10-14 18:29:23
|
On Tuesday, October 14, 2003, at 02:21 PM, Ian Bicking wrote: > On Tuesday, October 14, 2003, at 01:17 PM, Brad Bollenbach wrote: >> On Tuesday, October 14, 2003, at 02:05 PM, Ian Bicking wrote: >> >>> First, are you using CVS? There's a bug in 0.4 related to this. >>> CVS will be 0.5 once I package it up. >> >> Yep, just updated SQLObject a moment ago right from SourceForge to be >> double-sure. > > Can you double-check the installation? I definitely remember this bug > showing up with this exact same sort of exception in the past. If > that doesn't help, I won't be able to look at this until tonight. Ugh, I had a custom (older, of course) version of SQLObject living in the same directory as the relevant module being imported, so even though the CVS version of SQLObject was in the first directory in my PYTHONPATH, it was never getting seen. Moved that version out of the way so that the CVS version gets seen, and it Does The Right Thing now. I could use a dark corner to crawl into right now. -- Brad Bollenbach BBnet.ca |
From: Ian B. <ia...@co...> - 2003-10-14 18:21:36
|
On Tuesday, October 14, 2003, at 01:17 PM, Brad Bollenbach wrote: > On Tuesday, October 14, 2003, at 02:05 PM, Ian Bicking wrote: > >> First, are you using CVS? There's a bug in 0.4 related to this. CVS >> will be 0.5 once I package it up. > > Yep, just updated SQLObject a moment ago right from SourceForge to be > double-sure. Can you double-check the installation? I definitely remember this bug showing up with this exact same sort of exception in the past. If that doesn't help, I won't be able to look at this until tonight. -- Ian Bicking | ia...@co... | http://blog.ianbicking.org |
From: Brad B. <br...@bb...> - 2003-10-14 18:17:07
|
On Tuesday, October 14, 2003, at 02:05 PM, Ian Bicking wrote: > First, are you using CVS? There's a bug in 0.4 related to this. CVS > will be 0.5 once I package it up. Yep, just updated SQLObject a moment ago right from SourceForge to be double-sure. Same bug. -- Brad Bollenbach BBnet.ca |