AttributeError: 'com.inductiveautomation.ignition.common.script.Imm' object has no attribute 'db'

Can somebody shed some light on the error, that one of our customers got on Ignition 7.9.21...?

validateInputImeRecepture is a custom method on the root container to verify, if the recipe name is valid:

def validateInputImeRecepture(self):
	invalidMessageCompReceptura = self.getComponent("InvalidMessageReceptura")
	
	novareceptura = self.getComponent("txtImeRecepture").text
	if novareceptura != None:
		exists = system.db.runPrepQuery("SELECT COUNT(*) FROM recipes WHERE ime_recepture = ?", [novareceptura])[0][0]
		if len(novareceptura)==0 or exists:
			invalidMessageCompReceptura.text = u"Že obstaja!"
			invalidMessageCompReceptura.visible = True
			self.IsValidImeRecepture = False
			return
	
	invalidMessageCompReceptura.visible = False
	
	self.IsValidImeRecepture = True

line 12 is this line:

exists = system.db.runPrepQuery("SELECT COUNT(*) FROM recipes WHERE ime_recepture = ?", [novareceptura])[0][0]

It's interesting that this happens every now and then and not always...
Most of the time the call to this custom method works like it should.

Bug (rare race condition) in script environment setup for custom functions, IIRC. Not fixed until sometime in v8.1.

Two ways forward:

  • Upgrade :roll_eyes:

  • Move code to a project library script and make custom function a one-liner that delegates to the library. (I would do this latter anyways, everywhere, and for all events, too.)

4 Likes

OK, the upgrade is out of the question, so move the code to the project library it is...
Thanks, @pturmel :+1: :beers:

1 Like