[CalendarServer-changes] [9620] CalendarServer/branches/users/glyph/q

source_changes at macosforge.org source_changes at macosforge.org
Sat Aug 11 01:54:58 PDT 2012


Revision: 9620
          http://trac.macosforge.org/projects/calendarserver/changeset/9620
Author:   glyph at apple.com
Date:     2012-08-11 01:54:58 -0700 (Sat, 11 Aug 2012)
Log Message:
-----------
fail further down

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/q/

Modified: CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py
===================================================================
--- CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py	2012-08-11 08:54:57 UTC (rev 9619)
+++ CalendarServer/branches/users/glyph/q/twext/enterprise/dal/record.py	2012-08-11 08:54:58 UTC (rev 9620)
@@ -67,10 +67,21 @@
 
 
     @classmethod
+    def _primaryKeyExpression(cls):
+        return Tuple([ColumnSyntax(c) for c in cls.__tbl__.model.primaryKey])
+
+
+    def _primaryKeyValue(self):
+        val = []
+        for col in self._primaryKeyExpression().columns:
+            val.append(getattr(self, self.__class__.__colmap__[col]))
+
+
+    @classmethod
     @inlineCallbacks
     def load(cls, txn, *primaryKey):
         tbl = cls.__tbl__
-        pkey = Tuple([ColumnSyntax(c) for c in tbl.model.primaryKey])
+        pkey = cls._primaryKeyExpression()
         allColumns = list(tbl)
         slct = Select(allColumns, From=tbl,
                       Where=pkey == Tuple(map(Constant, primaryKey)))
@@ -117,7 +128,10 @@
         colmap = {}
         for k, v in kw.iteritems():
             colmap[self.__attrmap__[k]] = v
-        yield (Update(colmap, Where=Constant(True)).on(self.__txn__))
+        yield (Update(colmap,
+               Where=self._primaryKeyExpression() == self._primaryKeyValue()
+               ).on(self.__txn__))
+        self.__dict__.update(kw)
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20120811/1e203396/attachment-0001.html>


More information about the calendarserver-changes mailing list