I have a few Python keyword library keywords I'm using to create new content speedily from robots. They are:
def createObject(self, path, portal_type, id, **kwargs):
site = getSite()
container = site.restrictedTraverse(path.strip('/').split('/'))
obj = _createObjectByType(portal_type, container, id, **kwargs)
def createAR(self, path, **kwargs):
portal = getSite()
container = portal.restrictedTraverse(path.strip('/').split('/'))
obj = create_analysisrequest(container, container.REQUEST, kwargs)
I use createObject for great justice.
However my createAR causes me a conflict error. It's creating a few objects
(using just _createObjectByType() and unmarkCreationFlag()), but it fails to
create even the first object. Here's the much-abreviated call-path through PDB:
-> obj = create_analysisrequest(container, container.REQUEST, kwargs)
-> sample = create_sample(context, request, values)
-> sample = _createObjectByType('Sample', context, tmpID())
(Pdb) import transaction;transaction.savepoint()
*** ConflictError: database conflict error (oid 0x..., class bika.lims.content.client.Client)
(bika.lims.content.client.Client) is the "context" in which the Sample is created
Before unmarkCreationFlag, I can commit the transaction just fine.
Immediately after unmarkCreationFlag(), I can trigger a Conflict error for this object by committing.
I use this code path directly from unit tests, with success. From robot-library however, something's in the way. I would really appreciate any tips on how to debug this kind of thing, or considerations I may be unaware of, any ideas of things I could have forgotton... I am at a loss now!