mmerickel / wired

A service locator implementation for Python.
https://wired.readthedocs.io
MIT License
17 stars 9 forks source link

Lookup by class (instead of name) doesn't use fully qualified name #1

Closed pauleveritt closed 5 years ago

pauleveritt commented 5 years ago

I just did this in a test and was surprised it passed:

# from wired.samples.simple_factory import Greeter
class Greeter:
    pass
factory = registry.find_factory(Greeter)

I have a registry with wired.samples.simple_factory.Greeter registered. I made a local Greeter, expecting it to fail on lookup. It passed.

It appears wired only uses the class name, thus two different classes, same name but different modules/packages, would be considered "the same".

mmerickel commented 5 years ago

Thanks! I released 0.1.2 with a fix for this.

pauleveritt commented 5 years ago

I should have mentioned...let me fix things like this. :)

mmerickel commented 5 years ago

Oh sorry! The class-based stuff is a source of frustration for me in zope since it doesn't support using classes directly. I was embarrassed that my hacky code was broken!

pauleveritt commented 5 years ago

Though I might not have gotten the fix right, I could have submitted a test. My apologies.

Next up: provide better traceback messages when a lookup fails. wired doesn't say which lookup fails.