sqlobject-discuss Mailing List for SQLObject (Page 36)
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: Oleg B. <ph...@ph...> - 2010-07-30 09:54:03
|
On Fri, Jul 30, 2010 at 07:13:47AM +0200, Tom Coetser wrote: > I would like to use a validator with a PickleCol like this: > > ---------------- cut --------------------------------------------------------- > from formencode import validators > > class PTValidator(validators.FancyValidator): > > def validate_python(self, value, state): > # Do validation on value here before storing it in the db > print "value:", value > > > class PT(SQLObject): > pickled = PickleCol(validator=PTValidator) > > ---------------- cut --------------------------------------------------------- > > The problem is that (it seems) value is already pickled by the time it is > passed to the PTValidator.validate_pyton() method. > > Can anyone give me some example/advise on how to use validators on a pickle > column and being able to **validate** the value being stored only, but still > leaving SQLObject to deal with the pickling/unpickling? This is the way: from formencode import compound class PT(SQLObject): pickled = PickleCol() socol = PT.sqlmeta.columns['pickled'] validator = socol.validator socol.validator = compound.All.join(PTValidator(), validator) PTValidator.from_python will be called first, before String/BLOB/Pickle conversion; and PTValidator.to_python will be called last, after unPickle/BLOB/String conversion. And you raised an interesting question. Some user-supplied validators need to be run in "normal" (current) order - from_python called last, after all conversions, and to_python first. For example, I use a special validator in a CurrencyCol, and I certainly want its from_python get data after all decimal conversions. But some columns require a different order. Perhaps I need to add an additional validator ("before_validator"? "validator2"?) so user-supplied validator will be inserted into the other end of the list of validators. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Tom C. <su...@ic...> - 2010-07-30 05:33:15
|
Hi all, I would like to use a validator with a PickleCol like this: ---------------- cut --------------------------------------------------------- from formencode import validators class PTValidator(validators.FancyValidator): def validate_python(self, value, state): # Do validation on value here before storing it in the db print "value:", value class PT(SQLObject): pickled = PickleCol(validator=PTValidator) ---------------- cut --------------------------------------------------------- The problem is that (it seems) value is already pickled by the time it is passed to the PTValidator.validate_pyton() method. Can anyone give me some example/advise on how to use validators on a pickle column and being able to **validate** the value being stored only, but still leaving SQLObject to deal with the pickling/unpickling? Thanks, Tom |
From: Oleg B. <ph...@ph...> - 2010-07-22 13:46:14
|
On Thu, Jul 22, 2010 at 02:49:39PM +0200, Julien Syx wrote: > It's okay with the field name. > > I would like to have field/value. > It's okay to have field with : > > for col in rights.sqlmeta.columnList: > print "column:"+str(col.name)+ " | value:"+str(col) > > It returns to me : column:hosts_delete | value:<SOBoolCol hosts_delete> > > I tried col.value, but no way. > Have you an idea ? I didn't see docs nor exemple on web. If 'rights' is a row from the Rights table then rights.hosts_delete is the value of the column. To get the value by name use getattr(): for col in rights.sqlmeta.columnList: print "column:"+str(col.name)+ " | value:"+str(getattr(rights, col.name)) Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Julien S. <nep...@gm...> - 2010-07-22 12:50:08
|
It's okay with the field name. I would like to have field/value. It's okay to have field with : for col in rights.sqlmeta.columnList: print "column:"+str(col.name)+ " | value:"+str(col) It returns to me : column:hosts_delete | value:<SOBoolCol hosts_delete> I tried col.value, but no way. Have you an idea ? I didn't see docs nor exemple on web. Thanks a lot ! On Thu, Jul 22, 2010 at 10:47 AM, Julien Syx <nep...@gm...>wrote: > Shame on me, it was too late, i was tired :p > > That's do the trick. > > Thanks Oleg ;-) > > On Thu, Jul 22, 2010 at 8:02 AM, Oleg Broytman <ph...@ph...> wrote: > >> On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: >> > What i want to do is something like this : >> > >> > for columns in table: >> > print columns.name >> > >> > I defined my class like this : >> > Class Rights(SQLObject): >> > user_view = BoolCol >> > ... >> >> print Rights.sqlmeta.columnList >> print Rights.sqlmeta.columns >> print Rights.sqlmeta.joins >> print Rights.sqlmeta.indexes >> >> See the class sqlmeta in main.py. >> >> Oleg. >> -- >> Oleg Broytman http://phd.pp.ru/ ph...@ph... >> Programmers don't die, they just GOSUB without RETURN. >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Sprint >> What will you do first with EVO, the first 4G phone? >> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first >> _______________________________________________ >> sqlobject-discuss mailing list >> sql...@li... >> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss >> > > |
From: Julien S. <nep...@gm...> - 2010-07-22 08:47:33
|
Shame on me, it was too late, i was tired :p That's do the trick. Thanks Oleg ;-) On Thu, Jul 22, 2010 at 8:02 AM, Oleg Broytman <ph...@ph...> wrote: > On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: > > What i want to do is something like this : > > > > for columns in table: > > print columns.name > > > > I defined my class like this : > > Class Rights(SQLObject): > > user_view = BoolCol > > ... > > print Rights.sqlmeta.columnList > print Rights.sqlmeta.columns > print Rights.sqlmeta.joins > print Rights.sqlmeta.indexes > > See the class sqlmeta in main.py. > > Oleg. > -- > Oleg Broytman http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Sprint > What will you do first with EVO, the first 4G phone? > Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first > _______________________________________________ > sqlobject-discuss mailing list > sql...@li... > https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss > |
From: Oleg B. <ph...@ph...> - 2010-07-22 06:02:24
|
On Thu, Jul 22, 2010 at 02:04:21AM +0200, Julien Syx wrote: > What i want to do is something like this : > > for columns in table: > print columns.name > > I defined my class like this : > Class Rights(SQLObject): > user_view = BoolCol > ... print Rights.sqlmeta.columnList print Rights.sqlmeta.columns print Rights.sqlmeta.joins print Rights.sqlmeta.indexes See the class sqlmeta in main.py. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Julien S. <nep...@gm...> - 2010-07-22 00:04:49
|
Hello everyone, Sorry if the question was already asked, i searched but i didn't find anything. I want to know how can i do to have a list of columns in my table with my object. I explain, i have my object like this : <Rights 1 user_view=True user_create=True user_modify=False user_delete=False groups_view=True groups_create=False groups_modify=True groups_delete=False modules_execute=True modules_install=False modules_delete=True graphs_view=True graphs_create=False graphs_modify=True graphs_delete=True alerts_view=True alerts_create=True alerts_modify=True alerts_delete=True hosts_view=False hosts_create=True hosts_modify=False hosts_delete=True> What i want to do is something like this : for columns in table: print columns.name I defined my class like this : Class Rights(SQLObject): user_view = BoolCol ... Can you help me ? Thanks a lot ! |
From: Daniel F. <fet...@go...> - 2010-07-16 07:53:20
|
>> I'm pleased to announce version 0.13.0b1, the first beta version of a new >> upcoming release of branch 0.13 of SQLObject. > > There a few major changes in the branch so it needs to have a longer > beta period. > >> * Validators became stricter: StringCol and UnicodeCol now accept only >> str, >> unicode or an instance of a class that implements __unicode__ (but not >> __str__ because every object has a __str__ method); BoolCol accepts only >> bool or int or an instance of a class that implements __nonzero__; >> IntCol >> accepts int, long or an instance of a class that implements __int__ or >> __long__; FloatCol accepts float, int, long or an instance of a class >> that implements __float__, __int__ or __long__. > > I want to explain: with this I want to prevent things like > > class MyTable(SQLObject): > name = StringCol() > age = IntCol() > flag = BoolCol() > > row = MyTable(name=10, age='42', flag={}) > > I understand this is a controversial change. I can put arguments on both > sides, pro et contra. If there will be complaints I will reverse the > decision. I think this is a reasonable change. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2010-07-15 16:05:28
|
On Thu, Jul 15, 2010 at 07:58:08PM +0400, Oleg Broytman wrote: > I'm pleased to announce version 0.13.0b1, the first beta version of a new > upcoming release of branch 0.13 of SQLObject. There a few major changes in the branch so it needs to have a longer beta period. > * Validators became stricter: StringCol and UnicodeCol now accept only str, > unicode or an instance of a class that implements __unicode__ (but not > __str__ because every object has a __str__ method); BoolCol accepts only > bool or int or an instance of a class that implements __nonzero__; IntCol > accepts int, long or an instance of a class that implements __int__ or > __long__; FloatCol accepts float, int, long or an instance of a class > that implements __float__, __int__ or __long__. I want to explain: with this I want to prevent things like class MyTable(SQLObject): name = StringCol() age = IntCol() flag = BoolCol() row = MyTable(name=10, age='42', flag={}) I understand this is a controversial change. I can put arguments on both sides, pro et contra. If there will be complaints I will reverse the decision. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-15 15:58:24
|
Hello! I'm pleased to announce version 0.13.0b1, the first beta version of a new upcoming release of branch 0.13 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.13.0b1dev-r4218 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.12 --------------- Features & Interface ~~~~~~~~~~~~~~~~~~~~ * SQLObject instances that don't have a per-instance connection can be pickled and unpickled. * Validators became stricter: StringCol and UnicodeCol now accept only str, unicode or an instance of a class that implements __unicode__ (but not __str__ because every object has a __str__ method); BoolCol accepts only bool or int or an instance of a class that implements __nonzero__; IntCol accepts int, long or an instance of a class that implements __int__ or __long__; FloatCol accepts float, int, long or an instance of a class that implements __float__, __int__ or __long__. * Added a connection class for rdbhost.com (commercial Postgres-over-Web service). Small Features ~~~~~~~~~~~~~~ * Added TimedeltaCol; currently it's only implemented on PostgreSQL as an INTERVAL type. * Do not pollute the base sqlmeta class to allow Style to set idName. In the case of inherited idName inherited value takes precedence; to allow Style to set idName reset inherited idName to None. * Better handling of circular dependencies in sqlobject-admin - do not include the class in the list of other classes. * Renamed db_encoding to dbEncoding in UnicodeStringValidator. * A new parameter 'sslmode' was added to PostgresConnection. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-15 15:41:16
|
Hello! I'm pleased to announce version 0.12.5b1, a beta version of a minor bugfix release of branch 0.12 of SQLObject. What is SQLObject ================= SQLObject is an object-relational mapper. Your database tables are described as classes, and rows are instances of those classes. SQLObject is meant to be easy to use and quick to get started with. SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite, Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB). Where is SQLObject ================== Site: http://sqlobject.org Development: http://sqlobject.org/devel/ Mailing list: https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss Archives: http://news.gmane.org/gmane.comp.python.sqlobject Download: http://cheeseshop.python.org/pypi/SQLObject/0.12.5b1dev-r4211 News and changes: http://sqlobject.org/News.html What's New ========== News since 0.12.4 ----------------- * 'backend' parameter was renamed to 'driver'. To preserve backward compatibility 'backend' is recognized and will be recognized for some time. For a more complete list, please see the news: http://sqlobject.org/News.html Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-13 06:29:07
|
On Mon, Jul 12, 2010 at 11:12:54PM +0000, Mark wrote: > some of > my tables aren't really objects as much as linking tables. > In this case we have a User who has friends so I added a > Friends class (userid,friendid) It seems you want ForeignKey/MultipleJoin/RelatedJoin. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Frank W. <fra...@no...> - 2010-07-13 01:25:53
|
2010/7/13 Daniel: >> I seem to be uncomfortable using SQLObject because some of >> my tables aren't really objects as much as linking tables. >> In this case we have a User who has friends so I added a >> Friends class (userid,friendid) which isn't really an >> object in my mind. i think youre thinking of ForeignKeys: http://www.sqlobject.org/FAQ.html#id15 when referencing itself, you´ll have something like a user table and a user_user table, resulting in a n times m relationship between users (a.k.a. friends). hth, frank |
From: Daniel F. <fet...@go...> - 2010-07-12 23:41:51
|
> I need a single column of the table in list format format > based ie select col1 where foo. Can I do this? See http://www.mail-archive.com/sql...@li.../msg04736.html > Can I write my own sql? Whats the most efficient way to do this? See http://sqlobject.org/SQLBuilder.html > I seem to be uncomfortable using SQLObject because some of > my tables aren't really objects as much as linking tables. > In this case we have a User who has friends so I added a > Friends class (userid,friendid) which isn't really an > object in my mind. Well, a friend table is just as much a Friend object as a user table is a User object (in my mind, at least). Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Mark <mar...@gm...> - 2010-07-12 23:28:31
|
I need a single column of the table in list format format based ie select col1 where foo. Can I do this? Can I write my own sql? Whats the most efficient way to do this? I seem to be uncomfortable using SQLObject because some of my tables aren't really objects as much as linking tables. In this case we have a User who has friends so I added a Friends class (userid,friendid) which isn't really an object in my mind. |
From: Oleg B. <ph...@ph...> - 2010-07-06 20:47:51
|
On Tue, Jul 06, 2010 at 08:08:40PM +0000, Mark wrote: > I have a unique column, and need two rows to swap their values. > Is there a way to make the 2 updates at the same time or do I Can you do that with pure SQL? > have to update one of them to an unused value in the DB then > make the swap? Yes, I think this is the way to go. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Mark <mar...@gm...> - 2010-07-06 20:09:02
|
I have a unique column, and need two rows to swap their values. Is there a way to make the 2 updates at the same time or do I have to update one of them to an unused value in the DB then make the swap? |
From: Oleg B. <ph...@ph...> - 2010-07-05 12:56:43
|
On Mon, Jul 05, 2010 at 11:20:31AM +0200, Till Maas wrote: > Oleg Broytman wrote: > > MultipleJoin works together with a corresponding ForeignKey. .select() > > doesn't take them into account. So either you iterate over Packages row by > > row and use .builds attribute of every row, or construct the query > > manually > > Can you maybe give me a hint how to create the query I will. See below. > Or is there some support for using custom > queries in SQLObject that make SQL-Injections impossible e.g. by using > prepared statements? Unfortunately, no. > >> class PackageUpdate(SQLObject): > >> title = UnicodeCol(notNone=True, alternateID=True) > >> builds = RelatedJoin("PackageBuild")# > >> > >> class PackageBuild(SQLObject): > >> nvr = UnicodeCol(notNone=True, alternateID=True) > >> package = ForeignKey('Package') > >> updates = RelatedJoin("PackageUpdate") > >> > >> class Package(SQLObject): > >> name = UnicodeCol(alternateID=True, notNone=True) > >> builds = MultipleJoin('PackageBuild', > >> joinColumn='package_id') > >> > This is the query that does not work unexpectedly, because > query.append(PackageUpdate.q.builds == builds) > updates = PackageUpdate.select(AND(*query), orderBy=order).reversed()[:20] > creates this error: > AttributeError: PackageUpdate instance has no attribute 'builds' I will explain how RelatedJoin works and the reason for the error. To simplify my explanations I will omit class Package. RelatedJoins are always come in pairs - two tables points to each other. They look rather simple, but SQLObject does some magic to implement them. It creates an intermediate table that stores many-to-many references. There is nothing too magical about the table - it is just an ordinary SQL table. The only magical thing is that SQLObject creates it itself behind the scene and builds queries when one asks for attributes build.updates and update.builds. SQLObject doesn't promote these attributes to the .q. namespace, hence you cannot use them in .select(). Really, there is no PackageUpdate.q.builds, only update.builds (where 'update' is a row from the PackageUpdate table). Now we have to look under the hood. The intermediate table can be declared in SQLObject terms. For example, to add additional columns. See http://sqlobject.org/FAQ.html#how-can-i-define-my-own-intermediate-table-in-my-many-to-many-relationship In your particular case you need the table to explicitly build a join (to overcome the limitations in SQLObject that cannot build implicit may-to-many joins itself). The table declaration is class PackageBuildPackageUpdate(SQLObject): package_build = ForeignKey("PackageBuild") package_update = ForeignKey("PackageUpdate") (To name the intermediate table SQLObject combines the names of the related tables in alphabetical order. You can change the name if you use parameters intermediateTable='...') When one asks for update.builds SQLObject generates a query like this: PackageBuild.select( PackageBuild.q.id==PackageBuildPackageUpdate.q.package_buildID & PackageBuildPackageUpdate.q.package_updateID==update.id) All you need now is to extend that very query. SQLObject can slightly relive the pain of constructing such queries. It has a magic .j namespace to help to build complex joins. The query above can be rewritten as PackageBuild.select(PackageBuild.j.updates & PackageUpdate.q.id==update.id) Try to add your own joins to the query. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Mark <mar...@gm...> - 2010-07-04 21:25:01
|
> > subs_sel = list(BBSubs.select(BBSubs.q.user_id==1)) > > for sub in subs_sel: > > sub.topic = BBTopic.get(sub.topic_id) > > sub.post = BBPost.get(sub.topic.last_post_id) > > sub.forum = BBForum.get(sub.topic.forum_id) > > Why do you assign values explicitly Why not to use ForeignKey? > > > subs = sorted(subs_sel, lambda x: x.topic.last_post_id) > > I don't see any problem with the code. Can you write a short standalone > script that I can run to see the problem? > > Oleg. Thanks for the tip on ForeignKey, I've been doing a lot of the above without using it and I knew I was missing something. The problem was a missing key= in the sorted function as I typed from memory and forgot it. subs = sorted(subs_sel, key=lambda x: x.topic.last_post_id) |
From: Daniel F. <fet...@go...> - 2010-07-03 16:37:33
|
>> > It only works with psycopg[12] backends, and those backends only >> > understand 'sslmode' parameter - not certificate/keyfile/CA. >> >> Sorry - psycopg *drivers*. > > Wow, it seems a bolt struck through my head when I devised the name for > the parameter. In the afterthought naming it 'backend' seems rather wrong. > The backend is PostgreSQL, and *drivers* are psycopg and pygres. > I'd like to rename the parameter to 'driver' and apologize for the > inconvenience. To relive the pain I will preserve backward compatibility > for a version or two. Sounds like a reasonable idea. Cheers, Daniel -- Psss, psss, put it down! - http://www.cafepress.com/putitdown |
From: Oleg B. <ph...@ph...> - 2010-07-03 14:25:37
|
On Sat, Jul 03, 2010 at 11:53:00AM +0200, Till Maas wrote: > class PackageUpdate(SQLObject): > title = UnicodeCol(notNone=True, alternateID=True) > builds = RelatedJoin("PackageBuild")# > > class PackageBuild(SQLObject): > nvr = UnicodeCol(notNone=True, alternateID=True) > package = ForeignKey('Package') > updates = RelatedJoin("PackageUpdate") > > class Package(SQLObject): > name = UnicodeCol(alternateID=True, notNone=True) > builds = MultipleJoin('PackageBuild', joinColumn='package_id') > > > This does not work, This declarations don't work? Or some code that uses them? > but I cannot find any hint how I can use SQLObject to > get all package updates that contain builds for a certain package. > A SQL query would look like this: > > SELECT package_update.title > FROM package_update, package_build_package_update, package_build, package > WHERE package_update.id = package_build_package_update.package_update_id > AND package_build.id = package_build_package_update.package_build_id > AND package_build.package_id = package.id > AND package.name = "bash"; MultipleJoin works together with a corresponding ForeignKey. .select() doesn't take them into account. So either you iterate over Packages row by row and use .builds attribute of every row, or construct the query manually (and pass it to .select() call), or patch SQLObject so it understands joins better (and submit your patches for review). Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-02 16:00:01
|
> > It only works with psycopg[12] backends, and those backends only > > understand 'sslmode' parameter - not certificate/keyfile/CA. > > Sorry - psycopg *drivers*. Wow, it seems a bolt struck through my head when I devised the name for the parameter. In the afterthought naming it 'backend' seems rather wrong. The backend is PostgreSQL, and *drivers* are psycopg and pygres. I'd like to rename the parameter to 'driver' and apologize for the inconvenience. To relive the pain I will preserve backward compatibility for a version or two. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-02 15:46:42
|
On Fri, Jul 02, 2010 at 07:41:30PM +0400, Oleg Broytman wrote: > It only works with psycopg[12] backends, and those backends only > understand 'sslmode' parameter - not certificate/keyfile/CA. Sorry - psycopg *drivers*. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-02 15:41:42
|
Hello. I just added 'sslmode' to PostgresConnection - see commit 4199 in the Subversion repository. The syntax is postgresql://cumin@localhost/cumin?sslmode=require It only works with psycopg[12] backends, and those backends only understand 'sslmode' parameter - not certificate/keyfile/CA. Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |
From: Oleg B. <ph...@ph...> - 2010-07-01 19:35:40
|
On Thu, Jul 01, 2010 at 06:47:59PM +0000, Mark wrote: > I just set up my own forum, and am attempting to sort a user's subscriptions > by the last post in each thread(BBTopic). However the sorted function is > failing saying lambda only takes 1 argument but was given 2. I use this > sorted function on lists of non SQLObject objects and it works fine for me. > > Can you use sorted with a list returned from a select? > > Or is there a way for me to rewrite this? Perhaps using orderBy? > > > subs_sel = list(BBSubs.select(BBSubs.q.user_id==1)) > for sub in subs_sel: > sub.topic = BBTopic.get(sub.topic_id) > sub.post = BBPost.get(sub.topic.last_post_id) > sub.forum = BBForum.get(sub.topic.forum_id) Why do you assign values explicitly Why not to use ForeignKey? > subs = sorted(subs_sel, lambda x: x.topic.last_post_id) I don't see any problem with the code. Can you write a short standalone script that I can run to see the problem? Oleg. -- Oleg Broytman http://phd.pp.ru/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |