def formatted_tag_value(tag, value): if value == None: return tag elif type(value) in types.StringTypes: return u'%s = "%s"' % (tag, value) else: return u'%s = %s' % (tag, toStr(value))
def execute_http_request(action, args, db, options): """Executes a raw HTTP command (GET, PUT, POST, DELETE or HEAD) as specified on the command line.""" method = action.upper() if method not in HTTP_METHODS: raise UnrecognizedHTTPMethodError(u'Only supported HTTP methods are' u'%s and %s' % (' '.join(HTTP_METHODS[:-1], HTTP_METHODS[-1]))) if len(args) == 0: raise TooFewArgsForHTTPError(u'HTTP command %s requires a URI' % method) uri = args[0] tags = form_tag_value_pairs(args[1:]) if method == u'PUT': body = {tags[0].tag: tags[0].value} tags = tags[1:] else: body = None hash = {} for pair in tags: hash[pair.name] = pair.value status, result = db.call(method, uri, body, hash) Print(u'Status: %d' % status) Print(u'Result: %s' % toStr(result))
def __unicode__(self): return (u'Tag "%s", value "%s" of type %s' % (self.name, toStr(self.value), toStr(type(self.value))))