355: Object.set_api() now creates Object.params namespace by merging takes_params and properties together intelegintly

This commit is contained in:
Jason Gerard DeRose 2008-09-25 00:00:58 +00:00
parent f531f7da81
commit 79b33ad366
2 changed files with 19 additions and 10 deletions

View File

@ -520,21 +520,12 @@ class Object(plugable.Plugin):
params = None
takes_params = tuple()
def __create_params(self):
props = self.properties.__todict__()
for spec in self.takes_params:
if type(spec) is str and spec.rstrip('?*+') in props:
yield props.pop(spec.rstrip('?*+')).param
else:
yield create_param(spec)
def set_api(self, api):
super(Object, self).set_api(api)
self.methods = self.__create_namespace('Method')
self.properties = self.__create_namespace('Property')
self.params = plugable.NameSpace(
(create_param(p) for p in self.takes_params), sort=False
self.__create_params(), sort=False
)
def __create_namespace(self, name):
@ -547,6 +538,22 @@ class Object(plugable.Plugin):
if proxy.obj_name == self.name:
yield proxy.__clone__('attr_name')
def __create_params(self):
props = self.properties.__todict__()
for spec in self.takes_params:
if type(spec) is str and spec.rstrip('?*+') in props:
yield props.pop(spec.rstrip('?*+')).param
else:
yield create_param(spec)
def get_key(p):
if p.param.required:
if p.param.default_from is None:
return 0
return 1
return 2
for prop in sorted(props.itervalues(), key=get_key):
yield prop.param
class Attribute(plugable.Plugin):
__public__ = frozenset((

View File

@ -788,6 +788,8 @@ class test_Object(ClassChecker):
self.name = '%s_%s' % (obj_name, attr_name)
else:
self.name = name
self.param = frontend.create_param(attr_name)
def __clone__(self, attr_name):
return self.__class__(
self.obj_name,