349
348
__call__ = __str__
352
def make_simple_configuration(
353
attributes, request_class=Request, publication_class=Publication,
354
class_name="WebServiceConfiguration"):
355
"""Return a class that implements all of IWebServiceConfiguration.
357
The generated class will define all the attributes and have simple
358
implementations of the methods specified in
359
IWebServiceConfiguration. If you need different implementations of
360
the methods, define your own class and pass it into
361
make_configuration as 'superclass'.
363
attributes = dict(attributes)
364
if (not 'createRequest' in attributes and request_class is not None
365
and publication_class is not None):
366
def createRequest(self, body_instream, environ):
367
"""See `IWebServiceConfiguration`."""
368
request = request_class(body_instream, environ)
369
service_root_object = getUtility(IServiceRootResource)
370
request.setPublication(publication_class(service_root_object))
372
attributes['createRequest'] = createRequest
374
if not 'get_request_user' in attributes:
375
def get_request_user(self):
377
attributes['get_request_user'] = attributes
379
return make_configuration(attributes, class_name=class_name)
382
def make_configuration(attributes, superclass=object,
383
class_name="WebServiceConfiguration"):
384
"""Return an IWebServiceConfiguration implementation.
386
:param superclass: The superclass to use.
388
:param attributes: A dict of attribute values and method
389
definitions. This will be combined with the default values for
390
attributes defined in IWebServiceConfiguration.
392
Either 'superclass' must implement the methods defined in
393
IWebServiceConfiguration, or they must be provided in
394
'attributes'. Otherwise, your class won't work.
396
return implement_from_dict(
397
class_name, IWebServiceConfiguration, attributes, superclass)
351
BaseWebServiceConfiguration = implement_from_dict(
352
"BaseWebServiceConfiguration", IWebServiceConfiguration, {}, object)