mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 09:16:14 +01:00
- class Request: added create method in order to create a new request
- removed "self.readonly" attribute for now (maybe we need this in the future...)
This commit is contained in:
parent
955ee78e8b
commit
967719e566
13
osc/core.py
13
osc/core.py
@ -2345,6 +2345,10 @@ class Request:
|
|||||||
"""Represents a request (<request />)"""
|
"""Represents a request (<request />)"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self._init_attributes()
|
||||||
|
|
||||||
|
def _init_attributes(self):
|
||||||
|
"""initialize attributes with default values"""
|
||||||
self.reqid = None
|
self.reqid = None
|
||||||
self.title = ''
|
self.title = ''
|
||||||
self.description = ''
|
self.description = ''
|
||||||
@ -2352,11 +2356,10 @@ class Request:
|
|||||||
self.actions = []
|
self.actions = []
|
||||||
self.statehistory = []
|
self.statehistory = []
|
||||||
self.reviews = []
|
self.reviews = []
|
||||||
self.readonly = False
|
|
||||||
|
|
||||||
def read(self, root):
|
def read(self, root):
|
||||||
"""read in a request"""
|
"""read in a request"""
|
||||||
self.readonly = True
|
self._init_attributes()
|
||||||
if not root.get('id'):
|
if not root.get('id'):
|
||||||
raise oscerr.APIError('invalid request: %s\n' % ET.tostring(root))
|
raise oscerr.APIError('invalid request: %s\n' % ET.tostring(root))
|
||||||
self.reqid = root.get('id')
|
self.reqid = root.get('id')
|
||||||
@ -2516,6 +2519,12 @@ class Request:
|
|||||||
def __cmp__(self, other):
|
def __cmp__(self, other):
|
||||||
return cmp(self.reqid, other.reqid)
|
return cmp(self.reqid, other.reqid)
|
||||||
|
|
||||||
|
def create(self, apiurl):
|
||||||
|
"""create a new request"""
|
||||||
|
u = makeurl(apiurl, ['request'], query='cmd=create')
|
||||||
|
f = http_POST(u, data=self.to_str())
|
||||||
|
root = ET.fromstring(f.read())
|
||||||
|
self.read(root)
|
||||||
|
|
||||||
def shorttime(t):
|
def shorttime(t):
|
||||||
"""format time as Apr 02 18:19
|
"""format time as Apr 02 18:19
|
||||||
|
Loading…
Reference in New Issue
Block a user