Bug in the Python API 1.5.2 Create View?

585
2
12-17-2018 07:41 PM
FraserHand1
New Contributor III

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:

0 Kudos
2 Replies
JohnYaist1
Esri Contributor

Hi Fraser Hand  - the UserManager is accessed through the `users` property. The code you've highlighted looks incoorect in that it should be `gis.users.me.username`. I'll confirm and we'll correct that.

0 Kudos
FraserHand1
New Contributor III

Hi John,

Yes its a typo in the core code:

Thanks

0 Kudos