AnsweredAssumed Answered

Bug in the Python API 1.5.2 Create View?

Question asked by fsheagle-co-nz-esridist Employee on Dec 17, 2018
Latest reply on Dec 19, 2018 by fsheagle-co-nz-esridist

Hi,

I'm trying to create a hosted feature layer view via the feature layer collection manager in 10.6.1 with python API 1.5.2.

In the managers.py there is this

def create_view(self,
                name,
                spatial_reference=None,
                extent=None,
                allow_schema_changes=True,
                updateable=True,
                capabilities="Query",
                view_layers=None):

function, which has a block to get the username for the sharing API

 

if gis._url.lower().find("sharing/rest") < 0:
    url = gis._url + "/sharing/rest"
else:
    url = gis._url

if 'id' in gis.properties.user:
    me = gis.properties.user.id
else:
    me = gis.user.me.username
url = "%s/content/users/%s/createService" % (url, me)

I haven't got 'id' in the properties.user and there is no gis.user - and it's weird that this property isn't checked before attempting access - so the developer has assumed it will be present.

 

 

I'm using built in portal IDP. So looks like we have a missing test case?

I'm going to rewrite the code to fix this use case but interested to know why gis.user.me is missing from my GIS object.

Thanks

Fraser

 

EDIT: Assuming the line should be:

elif 'username' in gis.properties.user:

Outcomes