summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-09-23 10:01:56 +0000
committerGerrit Code Review <review@openstack.org>2013-09-23 10:01:56 +0000
commit4fd56a3f1a7f8391018521df0526ae5faac162e6 (patch)
tree8a4b606d61e53bac7bf46f119e4a98156ea502c1
parent17adf7d4c6a5c593f7ab96915477acebf0302775 (diff)
parenta04748e868f21b8c9a3e9bd8d8582ad22b1e2040 (diff)
downloadwsme-4fd56a3f1a7f8391018521df0526ae5faac162e6.tar.gz
Merge "Minor code cleanups"
-rw-r--r--wsme/api.py4
-rw-r--r--wsme/rest/__init__.py12
-rw-r--r--wsme/types.py7
-rw-r--r--wsmeext/sphinxext.py14
-rw-r--r--wsmeext/sqlalchemy/types.py2
5 files changed, 18 insertions, 21 deletions
diff --git a/wsme/api.py b/wsme/api.py
index 7de462c..6bd181d 100644
--- a/wsme/api.py
+++ b/wsme/api.py
@@ -83,8 +83,8 @@ class FunctionDefinition(object):
#: Dictionnary of protocol-specific options.
self.extra_options = None
- @classmethod
- def get(cls, func):
+ @staticmethod
+ def get(func):
"""
Returns the :class:`FunctionDefinition` of a method.
"""
diff --git a/wsme/rest/__init__.py b/wsme/rest/__init__.py
index 3153a49..f35d6a9 100644
--- a/wsme/rest/__init__.py
+++ b/wsme/rest/__init__.py
@@ -12,25 +12,25 @@ class expose(object):
return self.signature(func)
@classmethod
- def with_method(self, method, *args, **kwargs):
+ def with_method(cls, method, *args, **kwargs):
kwargs['method'] = method
- return expose(*args, **kwargs)
+ return cls(*args, **kwargs)
@classmethod
def get(cls, *args, **kwargs):
- return expose.with_method('GET', *args, **kwargs)
+ return cls.with_method('GET', *args, **kwargs)
@classmethod
def post(cls, *args, **kwargs):
- return expose.with_method('POST', *args, **kwargs)
+ return cls.with_method('POST', *args, **kwargs)
@classmethod
def put(cls, *args, **kwargs):
- return expose.with_method('PUT', *args, **kwargs)
+ return cls.with_method('PUT', *args, **kwargs)
@classmethod
def delete(cls, *args, **kwargs):
- return expose.with_method('DELETE', *args, **kwargs)
+ return cls.with_method('DELETE', *args, **kwargs)
class validate(object):
diff --git a/wsme/types.py b/wsme/types.py
index 41570e1..789cbd0 100644
--- a/wsme/types.py
+++ b/wsme/types.py
@@ -437,15 +437,12 @@ def inspect_class(class_):
if inspect.isroutine(attr):
continue
- if isinstance(attr, wsattr):
- attrdef = attr
- elif isinstance(attr, wsproperty):
+ if isinstance(attr, (wsattr, wsproperty)):
attrdef = attr
else:
if attr not in native_types and (
inspect.isclass(attr)
- or isinstance(attr, list)
- or isinstance(attr, dict)):
+ or isinstance(attr, (list, dict))):
register_type(attr)
attrdef = getattr(class_, '__wsattrclass__', wsattr)(attr)
diff --git a/wsmeext/sphinxext.py b/wsmeext/sphinxext.py
index 0f63f7b..f905e9a 100644
--- a/wsmeext/sphinxext.py
+++ b/wsmeext/sphinxext.py
@@ -76,7 +76,7 @@ class SampleType(object):
@classmethod
def sample(cls):
- return SampleType(10)
+ return cls(10)
class SampleService(wsme.WSRoot):
@@ -194,8 +194,8 @@ class TypeDocumenter(autodoc.ClassDocumenter):
'samples-slot': check_samples_slot,
})
- @classmethod
- def can_document_member(cls, member, membername, isattr, parent):
+ @staticmethod
+ def can_document_member(member, membername, isattr, parent):
# we don't want to be automaticaly used
# TODO check if the member is registered an an exposed type
return False
@@ -271,8 +271,8 @@ class AttributeDocumenter(autodoc.AttributeDocumenter):
datatype = None
domain = 'wsme'
- @classmethod
- def can_document_member(cls, member, membername, isattr, parent):
+ @staticmethod
+ def can_document_member(member, membername, isattr, parent):
return isinstance(parent, TypeDocumenter)
def import_object(self):
@@ -483,8 +483,8 @@ class FunctionDocumenter(autodoc.MethodDocumenter):
'method': directives.unchanged
}
- @classmethod
- def can_document_member(cls, member, membername, isattr, parent):
+ @staticmethod
+ def can_document_member(member, membername, isattr, parent):
return (isinstance(parent, ServiceDocumenter)
and wsme.api.iswsmefunction(member))
diff --git a/wsmeext/sqlalchemy/types.py b/wsmeext/sqlalchemy/types.py
index 13c67ec..da5603d 100644
--- a/wsmeext/sqlalchemy/types.py
+++ b/wsmeext/sqlalchemy/types.py
@@ -18,7 +18,7 @@ class SQLAlchemyRegistry(object):
@classmethod
def get(cls, registry):
if not hasattr(registry, 'sqlalchemy'):
- registry.sqlalchemy = SQLAlchemyRegistry()
+ registry.sqlalchemy = cls()
return registry.sqlalchemy
def __init__(self):