Repository navigation
Description
when trying to list the users in my instance (see following code)
syncano.connect(api_key=API_KEY)
users = User.please.list(instance_name=INSTANCE)
for user in users:
# print(user)
print(user.user_key)
I get the following error:
Traceback (most recent call last):
File "_**syncano_backend/test/test.py", line 34, in
for user in users:
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 812, in iterator
yield self.serialize(o)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/manager.py", line 741, in serialize
return model(__properties) if self._serialize else data
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 90, in init
self.to_python(kwargs)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/archetypes.py", line 247, in to_python
setattr(self, field.name, value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 105, in set
instance.raw_data[self.name] = self.to_python(value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/fields.py", line 524, in to_python
return self.rel(*value)
File "/usr/local/lib/python3.5/dist-packages/syncano/models/classes.py", line 145, in new
raise SyncanoValidationError('Field "instance_name" is required.')
syncano.exceptions.SyncanoValidationError: Field "instance_name" is required.
I tested my api key in http://docs.syncano.io/v0.1.1/docs/users-list and it worked. It looks like the python lib cant create a user model object from the response.
Code from the stacktrace
def serialize(self, data, model=None):
"""Serializes passed data to related :class:`~syncano.models.base.Model` class."""
model = model or self.model
if data == '':
return
if isinstance(data, model):
return data
if not isinstance(data, dict):
raise SyncanoValueError('Unsupported data type.')
properties = deepcopy(self.properties)
properties.update(data)
return model(**properties) if self._serialize else data`
Activity
MariuszWisniewski commentedon Sep 8, 2016
@opalczynski Can you please take a look?
opalczynski commentedon Sep 8, 2016
@lifcio will do.
MariuszWisniewski commentedon Sep 8, 2016
Thanks! I checked and it works when we pass
instance_nameas a parameter inconnectmethod, so maybe only our example in docs is wrong?opalczynski commentedon Sep 8, 2016
Ahh, this. Yep this is known bug :) By me. But to be honest - I have no idea how to solve it now :(
Eggwise commentedon Sep 11, 2016
Hi,
Ok, maybe i can fix the bug in my spare time.
thanks for the response.
Cheers
MariuszWisniewski commentedon Sep 11, 2016
@Eggwise Unless you need to connect to multiple Syncano instances in your app at once, you can try following code as a workaround for now (pass instance name in
connectinstead oflist):Eggwise commentedon Sep 11, 2016
@lifcio That is handy, thanks!
Maybe its good to update the documentation to prevent users from getting errors.
[#239] - Set instance_name in ModelFields after request made without …
[#239] - Make tests passing.
[#239] - Refactor, add tests.
[#239] - Fix broken tests.