def _get(subpath, **kwargs): url = _build(subpath, kwargs) log.debug('get -> %s', url) f = urllib.urlopen(url) b = Bag() b.fromXml(f.read()) return b
def _get(subpath, **kwargs): url = _build(subpath, kwargs) log.debug('get -> %s', url) f = urllib.urlopen(url) b = Bag() b.fromXml(f.read()) return b
def _post(subpath, bag=None): url = settings.BACKEND + subpath body = {} if bag is not None: body['data'] = bag.toXml() log.debug('post -> %s data: %s', unicode(url).encode('utf-8'), body['data'] if isinstance(body['data'], str) else body['data'].encode('utf-8')) else: log.debug('post -> %s', url) f = urllib.urlopen(url, urllib.urlencode(body)) b = Bag() b.fromXml(f.read()) return b
def _post(subpath, bag=None): url = settings.BACKEND + subpath body = {} if bag is not None: body['data'] = bag.toXml() log.debug( 'post -> %s data: %s', unicode(url).encode('utf-8'), body['data'] if isinstance( body['data'], str) else body['data'].encode('utf-8')) else: log.debug('post -> %s', url) f = urllib.urlopen(url, urllib.urlencode(body)) b = Bag() b.fromXml(f.read()) return b