Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added RESTful batch op support

  • Loading branch information...
commit c5e4117a7da8e202b38c534106e6da237bd9a8d4 1 parent df75849
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) authored
View
14 BEXML/bexmlsrv.py
@@ -202,6 +202,12 @@ def GET(self, api):
if api not in parserAPIs:
raise AssertionError, "API '"+api+"' not in allowed APIs: "+repr(parserAPIs)
reloaded=False
+ batchitems=1
+ if '__batch_items' in query:
+ batchitems=int(query['__batch_items'][0])
+ del query['__batch_items']
+ if batchitems<1: batchitems=1
+ elif batchitems>50: batchitems=50
if session.session_id in sessionToParserInfo:
pi=sessionToParserInfo[session.session_id]
else:
@@ -216,17 +222,19 @@ def GET(self, api):
for parameter in mandpars:
if parameter not in query:
raise AssertionError, "Mandatory parameter '"+parameter+"' is missing"
- # urlparse allows multiple values per parameter, we only want the first
+ # urlparse allows multiple values per parameter, we only want the first
+ for parameter in query:
query[parameter]=query[parameter][0]
result=method(**query)
if isinstance(result, types.GeneratorType):
pi.generators[method]=result
if method in pi.generators:
try:
- result=pi.generators[method].next()
+ result=[]
+ for n in xrange(0, batchitems):
+ result.append(pi.generators[method].next())
except StopIteration:
del pi.generators[method]
- result=None
return {'reloaded' : reloaded, 'result': result}
if __name__ == "__main__":
View
1  BEXML/libBEXML/propertieddictionary.py
@@ -256,6 +256,7 @@ def _match(self, filterstring):
>>> print x._match("niall")
False
"""
+ assert isinstance(filterstring, str), "Filter string '"+repr(filterstring)+"' is not a string"
if len(filterstring)==0: return False
# Break up into bits first ..
filters=[]
View
43 BEXML/tests/TestParseBErepoWithHTTP.py
@@ -18,8 +18,8 @@ def setUp(self):
self.emptyloop=end-start
self.cookies={}
- def request(self, api, pars=None):
- req=api+('?'+urllib.urlencode(pars) if pars is not None else "")
+ def request(self, api, **pars):
+ req=api+('?'+urllib.urlencode(pars) if len(pars)>0 else "")
headers={'Accept' : 'application/json'}
if len(self.cookies):
cookie=""
@@ -40,7 +40,7 @@ def request(self, api, pars=None):
def test(self):
print "API list is", self.request("/apilist")[0]
- self.request("/open", { 'uri' : "file://tests/bugs.bugseverywhere.org"})
+ self.request("/open", uri="file://tests/bugs.bugseverywhere.org")
print("\nIssues in the bugs everywhere repository:")
start=time.time()
@@ -51,16 +51,33 @@ def test(self):
start=time.time()
issues=comments=0
while True:
- data=self.request("/parseIssues")[0]
- issue=data['result']
- if issue is None: break
- issues+=1
- #print " "+issue['uuid']+": "+issue['summary']
- while True:
- data=self.request("/parseComments", {'issue_uuid': issue['uuid']})[0]
- comment=data['result']
- if comment is None: break
- comments+=1
+ data=self.request("/parseIssues", __batch_items=50)[0]
+ issues_=data['result']
+ issues+=len(issues_)
+ for issue in issues_:
+ #print " "+issue['uuid']+": "+issue['summary']
+ while True:
+ data=self.request("/parseComments", issue_uuid=issue['uuid'], __batch_items=50)[0]
+ comments_=data['result']
+ comments+=len(comments_)
+ for comment in comments_:
+ pass
+ if len(comments_)<50: break
+ if len(issues_)<50: break
+ end=time.time()
+ print("Reading %d issues and %d comments from the bugs everywhere repository for the first time took %f secs" % (issues, comments, end-start-self.emptyloop))
+
+ print("\nIssues created by anyone called Steve:")
+ start=time.time()
+ issues=comments=0
+ while True:
+ data=self.request("/parseIssues", issuefilter="{{creator}}:{{Steve}}", __batch_items=50)[0]
+ issues_=data['result']
+ issues+=len(issues_)
+ for issue in issues_:
+ #print " "+issue['uuid']+": "+issue['summary']
+ pass
+ if len(issues_)<50: break
end=time.time()
print("Reading %d issues and %d comments from the bugs everywhere repository for the first time took %f secs" % (issues, comments, end-start-self.emptyloop))
Please sign in to comment.
Something went wrong with that request. Please try again.