class SignedFileRequest(SignedRequest):
def __init__(self, host, path, node_id = None, name=None, \
content_type=None, hash=None, ssl=False, expires=0):
super(SignedFileRequest, self).__init__(host, path, ssl, expires)
self.name = name
self.content_type = content_type
self.hash = hash
self.node_id = node_id
def get_name(self):
return self.query_dict.get(NAME_KEY)
def set_name(self, value):
self.query_dict[NAME_KEY] = value
def get_content_type(self):
return self.query_dict.get(CONTENT_TYPE_KEY)
def set_content_type(self, value):
self.query_dict[CONTENT_TYPE_KEY] = value
def get_hash(self):
return self.query_dict.get(HASH_KEY)
def set_hash(self, value):
self.query_dict[HASH_KEY] = value
def get_node_id(self):
return self.query_dict.get(NODE_ID_KEY)
def set_node_id(self, value):
self.query_dict[NODE_ID_KEY] = value
name = property(get_name, set_name)
content_type = property(get_content_type, set_content_type)
hash = property(get_hash, set_hash)
node_id = property(get_node_id, set_node_id)
class SignedFileRequest(SignedRequest): def __init__(self, host, path, node_id = None, name=None, \ content_type=None, hash=None, ssl=False,
Share
You could use the
__getattr__and__setattr__hooks instead of a meta class:Alternatively, the same mapping can be used to create a class decorator:
Or you could go with a meta class approach anyway:
The latter reuses the
add_propertyfunction from the decorator approach.