Merlijn, You'll note that the docs for auto_accessors <https://pythonhosted.org/charms.reactive/charms.reactive.relations.html#charms.reactive.relations.RelationBase.auto_accessors> says that it's not a good idea to use with non-GLOBAL scoped relations, for this very reason. The problem is that there's no way which unit's or service's host and port you are trying to get, since there could be many. If it's true that there should only be a single connected service on this relation, then you should switch it to GLOBAL scope to indicate that. Otherwise, you need to be handling the possibility of multiple connected units explicitly.
See https://github.com/johnsca/juju-relation-mysql/blob/master/provides.py#L74 for an example of how an interface layer should handle multiple conversations. On Mon, Oct 26, 2015 at 5:58 AM, Merlijn Sebrechts < [email protected]> wrote: > Hi all > > > I have the following piece of code that reacts to the > httprelation.available hook (called rest2jfed in this case): > > > @when('rest2jfed.available') > def setup_rest2jfed(rest2jfed): > hostname = rest2jfed.host() > port = rest2jfed.port() > # Do some stuff with hostname and port > hookenv.status_set('active', 'Ready') > > > This piece of code gets called on the upgrade-charm hook. This throws an > error because there is not a relationship context. > > File "lib/charms/reactive/relations.py", line 88, in __accessor > return self.get_remote(field) > File "lib/charms/reactive/relations.py", line 308, in get_remote > return self.conversation(scope).get_remote(key, default) > File "lib/charms/reactive/relations.py", line 255, in conversation > raise ValueError('Unable to determine default scope: no current hook > or global scope') > > Am I using this relation wrong or is this a bug? > > > > Kind regards > Merlijn > > -- > Juju mailing list > [email protected] > Modify settings or unsubscribe at: > https://lists.ubuntu.com/mailman/listinfo/juju > >
-- Juju mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju
