Esri / ArcREST

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

GPObjects enhancement #232

Closed adamkerz closed 8 years ago

adamkerz commented 8 years ago

It would be great to be able to create GPObjects for submitting a job in one step instead of three lines. Currently:

layerName=GPString()
layerName.paramName='layerName'
layerName.value='myLayer'
gptask.submitJob([layerName])

Would be better to have this option:

gptask.submitJob([GPString('layerName','myLayer'])

I think this would mostly be backwards compatible by adding optional constructor parameters:

class GPString():
    def __init__(self,paramName=None,value=None):
        self.paramName=paramName
        self.value=value

As a side note, adding getters and setters for attributes that do nothing more than get/set really should be removed and just refer to the attribute its self. Eg:

@property
def value(self):
    """represents the object as a dictionary"""
    return self._value
#----------------------------------------------------------------------
@value.setter
def value(self, value):
    """gets/sets the object as a dictionary"""
    self._value = value

Is better as:

def __init__(self):
    self.value=None

Not to mention that, paramName's getter/setter, which does a simple str type check, should really be moved to the base class instead of repeated. There are many things in this code that would make it much more readable and maintainable and this would definitely help encourage contributions from others.

achapkowski commented 8 years ago

@adamkerz very good points. I'll take a look.