mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
More Python exception bubbling and SIP enum fix
This commit is contained in:
parent
4cc7a0ffa6
commit
dab7481083
@ -80,7 +80,7 @@ QgsServerOgcApi constructor
|
||||
|
||||
~QgsServerOgcApi();
|
||||
|
||||
virtual void executeRequest( const QgsServerApiContext &context ) const throw( QgsServerApiBadRequestException ) /VirtualErrorHandler=serverapi_badrequest_exception_handler/;
|
||||
virtual void executeRequest( const QgsServerApiContext &context ) const;
|
||||
%Docstring
|
||||
Executes a request by passing the given ``context`` to the API handlers.
|
||||
%End
|
||||
|
@ -101,14 +101,15 @@ Returns the default response content type in case the client did not specificall
|
||||
ask for any particular content type.
|
||||
%End
|
||||
|
||||
virtual QList<QgsServerOgcApi::ContentType> contentTypes() const;
|
||||
|
||||
virtual QList<int> contentTypesInt() const /PyName=contentTypes/;
|
||||
%Docstring
|
||||
Returns the list of content types this handler can serve, default to JSON and HTML.
|
||||
In case a specialized type (such as GEOJSON) is supported,
|
||||
the generic type (such as JSON) should not be listed.
|
||||
%End
|
||||
|
||||
virtual void handleRequest( const QgsServerApiContext &context ) const = 0;
|
||||
virtual void handleRequest( const QgsServerApiContext &context ) const throw( QgsServerApiBadRequestException ) /VirtualErrorHandler=serverapi_badrequest_exception_handler/;
|
||||
%Docstring
|
||||
Handles the request within its ``context``
|
||||
|
||||
@ -149,7 +150,7 @@ returns an empty string if there are not matches.
|
||||
|
||||
|
||||
|
||||
void write( QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata = QVariantMap() ) const;
|
||||
void write( QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata = QVariantMap() ) const throw( QgsServerApiBadRequestException );
|
||||
%Docstring
|
||||
Writes ``data`` to the ``context`` response stream, content-type is calculated from the ``context`` request,
|
||||
optional ``htmlMetadata`` for the HTML templates can be specified and will be added as "metadata" to
|
||||
|
@ -101,7 +101,7 @@ class SERVER_EXPORT QgsServerOgcApi : public QgsServerApi
|
||||
/**
|
||||
* Executes a request by passing the given \a context to the API handlers.
|
||||
*/
|
||||
virtual void executeRequest( const QgsServerApiContext &context ) const override SIP_THROW( QgsServerApiBadRequestException ) SIP_VIRTUALERRORHANDLER( serverapi_badrequest_exception_handler );
|
||||
virtual void executeRequest( const QgsServerApiContext &context ) const override;
|
||||
|
||||
/**
|
||||
* Returns a map of contentType => mime type
|
||||
|
@ -66,6 +66,29 @@ QgsServerOgcApiHandler::~QgsServerOgcApiHandler()
|
||||
//qDebug() << "handler destroyed";
|
||||
}
|
||||
|
||||
QList<QgsServerOgcApi::ContentType> QgsServerOgcApiHandler::contentTypes() const
|
||||
{
|
||||
return { QgsServerOgcApi::ContentType::JSON, QgsServerOgcApi::ContentType::HTML };
|
||||
}
|
||||
|
||||
void QgsServerOgcApiHandler::handleRequest( const QgsServerApiContext &context ) const
|
||||
{
|
||||
Q_UNUSED( context );
|
||||
throw QgsServerApiNotImplementedException( QStringLiteral( "Subclasses must implement handleRequest" ) );
|
||||
}
|
||||
|
||||
QList<int> QgsServerOgcApiHandler::contentTypesInt() const
|
||||
{
|
||||
QList<int> ret;
|
||||
const QList<QgsServerOgcApi::ContentType> constCt { contentTypes() };
|
||||
for ( const QgsServerOgcApi::ContentType &t : constCt )
|
||||
{
|
||||
ret.push_back( static_cast<int>( t ) );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
QString QgsServerOgcApiHandler::contentTypeForAccept( const QString &accept ) const
|
||||
{
|
||||
|
||||
|
@ -115,8 +115,16 @@ class SERVER_EXPORT QgsServerOgcApiHandler
|
||||
* Returns the list of content types this handler can serve, default to JSON and HTML.
|
||||
* In case a specialized type (such as GEOJSON) is supported,
|
||||
* the generic type (such as JSON) should not be listed.
|
||||
* \note not available in Python bindings
|
||||
*/
|
||||
virtual QList<QgsServerOgcApi::ContentType> contentTypes() const { return { QgsServerOgcApi::ContentType::JSON, QgsServerOgcApi::ContentType::HTML }; }
|
||||
virtual QList<QgsServerOgcApi::ContentType> contentTypes() const SIP_SKIP;
|
||||
|
||||
/**
|
||||
* Returns the list of content types this handler can serve, default to JSON and HTML.
|
||||
* In case a specialized type (such as GEOJSON) is supported,
|
||||
* the generic type (such as JSON) should not be listed.
|
||||
*/
|
||||
virtual QList<int> contentTypesInt() const SIP_PYNAME( contentTypes );
|
||||
|
||||
/**
|
||||
* Handles the request within its \a context
|
||||
@ -126,7 +134,7 @@ class SERVER_EXPORT QgsServerOgcApiHandler
|
||||
*
|
||||
* \throws QgsServerApiBadRequestError if the method encounters any error
|
||||
*/
|
||||
virtual void handleRequest( const QgsServerApiContext &context ) const = 0;
|
||||
virtual void handleRequest( const QgsServerApiContext &context ) const SIP_THROW( QgsServerApiBadRequestException ) SIP_VIRTUALERRORHANDLER( serverapi_badrequest_exception_handler );
|
||||
|
||||
/**
|
||||
* Analyzes the incoming request \a context and returns the validated
|
||||
@ -266,7 +274,7 @@ class SERVER_EXPORT QgsServerOgcApiHandler
|
||||
* - content_type_name( content_type ): returns a short name from a content type for example "text/html" will return "HTML"
|
||||
*
|
||||
*/
|
||||
void write( QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata = QVariantMap() ) const;
|
||||
void write( QVariant &data, const QgsServerApiContext &context, const QVariantMap &htmlMetadata = QVariantMap() ) const SIP_THROW( QgsServerApiBadRequestException );
|
||||
|
||||
/**
|
||||
* Returns an URL to self, to be used for links to the current resources and as a base for constructing links to sub-resources
|
||||
|
Loading…
x
Reference in New Issue
Block a user