primary key set in class's fields attribute intead of as its own class attribute
authorTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 12 Oct 2012 20:18:14 +0000 (16:18 -0400)
committerTony Mack <tmack@paris.CS.Princeton.EDU>
Fri, 12 Oct 2012 20:18:14 +0000 (16:18 -0400)
PLC/Accessors/Factory.py

index fec0d63..d4fe8b5 100644 (file)
@@ -110,7 +110,10 @@ def define_accessors_ (module, objclass, methodsuffix, tagname,
 
     # accepts
     get_accepts = [ Auth () ]
-    primary_key=objclass.primary_key
+    primary_key = None
+    for field in objclass.fields:
+        if objclass.fields[field].primary_key == True:
+            primary_key = field
     secondary_key = taggable_classes[objclass]['secondary_key']
     get_accepts += [ Mixed (objclass.fields[primary_key], objclass.fields[secondary_key]) ]
     # for set, idem set of arguments + one additional arg, the new value