def ows_security_tween_factory(handler, registry):
security = owssecurity_factory(registry)<EOL>def ows_security_tween(request):<EOL><INDENT>try:<EOL><INDENT>security.check_request(request)<EOL>return handler(request)<EOL><DEDENT>except OWSException as err:<EOL><INDENT>logger.exception("<STR_LIT>")<EOL>return err<EOL><DEDENT>except Exception as err:<EOL><INDENT>logger.exception("<STR_LIT>")<EOL>return OWSNoApplicableCode("<STR_LIT:{}>".format(err))<EOL><DEDENT><DEDENT>return ows_security_tween<EOL>
A tween factory which produces a tween which raises an exception
    if access to OWS service is not allowed.