Skip to content

Loading…

Allow adding domains to an app that does not have domains yet. #6

Closed
wants to merge 1 commit into from

1 participant

@ojii

Currently, trying to cloud.apps[0].domains.add('mydomain.com') does not work if cloud.apps[0] does not have domains yet, as in this case the app keyword to heroku.api.HerokuCore._get_resources from heroku.models.App.domains is lost. This patch stores the keyword arguments passed to _get_resources on the KeyedListResource and uses it in its add method.

@ojii

just noticed that this is a bit buggy, sorry

@ojii ojii closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 7 additions and 2 deletions.
  1. +1 −0 heroku/api.py
  2. +6 −2 heroku/structures.py
View
1 heroku/api.py
@@ -120,6 +120,7 @@ def _get_resources(self, resource, obj, params=None, map=None, **kwargs):
list_resource = map(items=items)
list_resource._h = self
list_resource._obj = obj
+ list_resource._kwargs = kwargs
return list_resource
View
8 heroku/structures.py
@@ -17,6 +17,7 @@ def __init__(self, items=None):
self._h = None
self._items = items or list()
self._obj = None
+ self._kwargs = {}
def __repr__(self):
return repr(self._items)
@@ -40,14 +41,17 @@ def __getitem__(self, key):
return v
def add(self, *args, **kwargs):
+ full_kwargs = {}
+ full_kwargs.update(self._kwargs)
+ full_kwargs.update(kwargs)
try:
- return self[0].new(*args, **kwargs)
+ return self[0].new(*args, **full_kwargs)
except IndexError:
o = self._obj()
o._h = self._h
- return o.new(*args, **kwargs)
+ return o.new(*args, **full_kwargs)
def remove(self, key):
Something went wrong with that request. Please try again.