@@ -325,7 +325,6 @@ class Endpoint(object):
325325 def __init__ (self , service , path ):
326326 self .service = service
327327 self .path = path if path .endswith ('/' ) else path + '/'
328- print "At init: %s" % self .path
329328
330329 def get (self , path_segment = "" , owner = None , app = None , sharing = None , ** query ):
331330 """GET from *path_segment* relative to this endpoint.
@@ -374,10 +373,10 @@ def get(self, path_segment="", owner=None, app=None, sharing=None, **query):
374373 # self.path to the Endpoint is relative in the SDK, so passing
375374 # owner, app, sharing, etc. along will produce the correct
376375 # namespace in the final request.
377- print "Path = %s" % self . path
378- print "Segment = %s" % path_segment
379- path = self . path + path_segment
380- import pprint ; pprint . pprint ( path )
376+ if path_segment . startswith ( '/' ):
377+ path = path_segment
378+ else :
379+ path = self . path + path_segment
381380 # ^-- This was "%s%s" % (self.path, path_segment).
382381 # That doesn't work, because self.path may be UrlEncoded.
383382 return self .service .get (path ,
@@ -1175,13 +1174,18 @@ def __call__(self, *args):
11751174 return self .list (* args )
11761175
11771176 def __getitem__ (self , key ):
1177+ if isinstance (key , tuple ) and len (key ) == 2 :
1178+ kind , key = key
1179+ else :
1180+ kind = None
11781181 candidate = None
11791182 for input in self .list ():
1180- if input .name == key :
1183+ if input .name == key and ( kind is None or input . kind == kind ) :
11811184 if candidate is None :
11821185 candidate = input
11831186 else :
1184- raise ValueError ("Found multiple inputs named '%s'; please specify an input kind." % key )
1187+ raise ValueError ("Found multiple inputs named '%s' (kinds: %s, %s); please specify an input kind." % \
1188+ (key , candidate .kind , input .kind ))
11851189 if candidate is not None :
11861190 return candidate
11871191 else :
@@ -1205,12 +1209,16 @@ def create(self, kind, name, **kwargs):
12051209 self .service .post (kindpath , name = name , ** kwargs )
12061210 return Input (self .service , _path (kindpath , name ), kind )
12071211
1208- def delete (self , name ):
1212+ def delete (self , kind , name = None ):
12091213 """Removes an input from the collection.
12101214
12111215 :param `name`: The name of the input to remove.
12121216 """
1213- self .service .delete (self [name ].path ) # UNDONE: Should be item.remove()
1217+ if name is None :
1218+ name = kind
1219+ self .service .delete (self [name ].path )
1220+ else :
1221+ self .service .delete (self [kind , name ].path )
12141222 return self
12151223
12161224 def itemmeta (self , kind ):
@@ -1262,8 +1270,6 @@ def list(self, *args):
12621270 # should be of type UrlEncoded, and all str should not
12631271 # be URL encoded.
12641272 path = urllib .unquote (state .links .alternate )
1265- print "Alternate link: %s" % path
1266-
12671273 entity = Input (self .service , path , kind , state = state )
12681274 entities .append (entity )
12691275
0 commit comments