[kforge-dev] Python bug?

John Bywater john.bywater at appropriatesoftwarefoundation.org
Fri Dec 16 16:07:34 UTC 2005

There isn't a Python bug, just that Registers implement Python dict, and 
so are False when empty:

I Googled "truth Python" and found this page:


"Any object can be tested for truth value, for use in an if or while 

"The following values are considered false:

* any empty sequence, for example, '', (), []
* any empty mapping, for example, {}"

The Register I was checking for 'truth' is implemented to behave as a 
Python dict, and so when a new Register, with no registered 
DomainObjects, is evaluated for truth it can be expected to evaluate to 

So, "if plugin.register" means "does the register have any 
DomainObjects" rather than "has a register been set".

For example:

registry.persons == True

registry.persons['admin'].sessions == False

I'll add "hasRegister(self): return self.register != None" to the plugin 
system PluginBase class: (I was checking if a Plugin extends the Domain 
Model in the service view class).


More information about the kforge-dev mailing list