Skip to content

Commit acdcfb4

Browse files
committed
Merge pull request #7 from RallyTools/master
incorporate small community pull requests from RallyTools/RallyRestToolkitForPython prior to 1.1.1 additions
2 parents 2737aaf + b8d4123 commit acdcfb4

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

pyral/context.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,13 @@ def _getDefaults(self, response):
302302
## print projects.content
303303
##
304304
if projects:
305-
proj = projects.next()
306-
proj_ref = proj._ref
307-
self._defaultProject = proj.Name
308-
self._currentProject = proj.Name
305+
try:
306+
proj = projects.next()
307+
proj_ref = proj._ref
308+
self._defaultProject = proj.Name
309+
self._currentProject = proj.Name
310+
except StopIteration: # The default workspace might not have any projects
311+
pass
309312
##
310313
## print " Default Workspace : %s" % self._defaultWorkspace
311314
## print " Default Project : %s" % self._defaultProject

pyral/rallyresp.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,15 @@ def _item(self):
241241
def __iter__(self):
242242
return self
243243

244+
def __nonzero__(self):
245+
"""
246+
This is for evaluating any invalid response as False.
247+
"""
248+
if 200 <= self.status_code < 300:
249+
return True
250+
else:
251+
return False
252+
244253
def next(self):
245254
"""
246255
Return a hydrated instance from the self.page until the page is exhausted,
@@ -367,7 +376,7 @@ def __repr__(self):
367376
blurb = self.warnings[0]
368377
else:
369378
blurb = "%sResult TotalResultCount: %d Results: %s" % \
370-
(self.req_type, self.resultCount, self.content['Results'])
379+
(self.request_type, self.resultCount, self.content['Results'])
371380
return "%s %s" % (self.status_code, blurb)
372381

373382
##################################################################################################

pyral/restapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def getProject(self, name=None):
433433
hits = [(proj,ref) for proj,ref in projs if str(proj) == str(name)]
434434
if not hits:
435435
return None
436-
tp = projs[0]
436+
tp = hits[0]
437437
tp_ref = tp[1]
438438
return _createShellInstance(context, 'Project', name, tp_ref)
439439

0 commit comments

Comments
 (0)