multiple instance of V1Meta register new username/password given
mtalexan opened this issue · 1 comments
Copied from versionone#24
If I create an instance of V1Meta with the correct username/password, and later on create another instance of V1Meta where the username/password is incorrect. The second instance of V1Meta will still be able to access the same information the first V1Meta instance can access.
v1 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="api", scheme="https") v1.Member(20).Name 'Administrator' v2 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="fake", scheme="https") v2.Member(20).Name 'Administrator'
Now the same can go if I flip this around and use a bad password in the first instance. If I create a second instance with the correct password, it will no longer work. So it does not appear we can have more than one instance of a V1Meta that will work as expected.
from v1pysdk import V1Meta v1 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="fake", scheme="https") v1.Member(20).Name Traceback (most recent call last): .... urllib2.HTTPError: HTTP Error 401: basic auth failed v2 = V1Meta(address="www14.v1host.com", instance="v1sdktesting", username="api", password="api", scheme="https") v2.Member(20).Name Traceback (most recent call last): .... urllib2.HTTPError: HTTP Error 401: basic auth failed
And
I didn`t get a chance to update this till now but this issue was caused by bad caching and the memoized decorator was persisting data between V1Meta instances even if the meta data changed.
So to resolve this all you need to do is just make sure the data variable under the cached_by_keyfunc method is created in the V1Meta instance.
This might be related to the larger issue in #23 as well. The V1Meta parameters may be getting memoized as static attributes across the class rather than per-instance. It may have to be moved away from the @memoization
decorator if that's being applied as a static class memoization.