On Saturday 25 February 2006 11:27, you wrote:
> I think FOR UPDATE would be a good addition. I would expect it to be a
> parameter passed through to select. Even if people decide to go with a flag
> in the table definition, I think the parameter to select is still required
> to override the flag for the common case of only needing FOR UPDATE in rare
> situations.

OK, I have reworked the support for "select for update" so that it now looks 
like
  obj.select(forUpdate = True)

Patch and testcase attached.

I didn't include a documentation patch since I'm not sure where it should go;
e.g. the connection parameter of select isn't documented in SQLObject.txt
(which is entry-level docu, not complete docu so it's understandable), and
select() isn't in interface.py.

-- 
David Faure -- [EMAIL PROTECTED], [EMAIL PROTECTED]
KDE/KOffice developer, Qt consultancy projects
Klarälvdalens Datakonsult AB, Platform-independent software solutions
Index: dbconnection.py
===================================================================
--- dbconnection.py	(revision 1640)
+++ dbconnection.py	(working copy)
@@ -501,6 +501,9 @@
 
         q = startSelect + ' ' + q
 
+        if ops.get('forUpdate'):
+            q += " FOR UPDATE";
+
         if limit and (start or end):
             # @@: Raising an error might be an annoyance, but some warning is
             # in order.
Index: main.py
===================================================================
--- main.py	(revision 1640)
+++ main.py	(working copy)
@@ -1313,7 +1313,7 @@
                orderBy=NoDefault, limit=None,
                lazyColumns=False, reversed=False,
                distinct=False, connection=None,
-               join=None):
+               join=None, forUpdate=False):
         return cls.SelectResultsClass(cls, clause,
                              clauseTables=clauseTables,
                              orderBy=orderBy,
@@ -1322,7 +1322,8 @@
                              reversed=reversed,
                              distinct=distinct,
                              connection=connection,
-                             join=join)
+                             join=join,
+                             forUpdate=forUpdate)
     select = classmethod(select)
 
     def selectBy(cls, connection=None, **kw):

Attachment: sqlrace.py
Description: application/python

Reply via email to