Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

Handle servers with no folders except root #303

Closed catstavi closed 7 years ago

catstavi commented 7 years ago

Using the ArcRest library, I ran into an issue where a server had no folders, but many services at the root level. This caused the _folders attribute to be set to None rather than an empty array, or an array with ['root']. Having the attribute folders set to None (despite a successful call) throws exceptions in various cases where the code expects folders to be iterable (for example, the currentFolder setter).

achapkowski commented 7 years ago

@catstavi I can't reproduce this.

catstavi commented 7 years ago

Ok! Here's how it repros for me:

>>> from arcrest.ags.server import Server
>>> s = Server("https://services.arcgis.com/vPD5PVLI6sfkZ5E4/arcgis/rest/services", None)
>>> s.folders  #returns None
>>> s.currentFolder
'root'
>>> s.services
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/arcrest/ags/server.py", line 163, in services
    for service in self._services:
TypeError: 'NoneType' object is not iterable

The issue being that there are many services at root level. Let me know if you're experiencing something different, or if I can provide any more info!