zope.component getUtility doesn't return instance attributes
Bug #1276421 reported by
Jean Jordaan
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zope 3 |
Invalid
|
Undecided
|
Unassigned |
Bug Description
I was having an issue with `hl.plone.
At the debug prompt, the issue looks like this:
```
>>> mh = getUtility(
>>> mh
<MailHost at /plone/MailHost>
>>> app.plone.MailHost
<MailHost at /plone/MailHost>
>>> mh.smtp_queue
False
>>> app.plone.
True
```
A working hack was to replace this line `mh = getUtility(
with this:
```
site = getUtility(
mh = site.MailHost
```
Somehow the `smtp_queue` attribute is getting lost when the mailhost is being looked up as utility, but not when it is found by attribute access.
To post a comment you must log in.
Without more context it's hard so tell, but this looks like it might be a hierarchy issue.
zope.component. getUtility( ) uses the "current site" to look up utilities, so it might well be that the global registry has one MailHost instance registered as a utility (which has smtp_queue=False), and your site has another instance registered (which has smtp_queue=True), and then somewhere there's a mixup about what the current site should be when looking up the utility.
But as I said, that's just a wild guess.