Skip to content

Commit d7d5977

Browse files
committed
Merge pull request #2206 from elpaso/server-docs-server-iface-fix
[SERVER] Server docs and server iface fix
2 parents 2b5ea36 + 0312dbf commit d7d5977

12 files changed

+47
-15
lines changed

doc/modules.dox

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ high level tools for carrying out spatial analysis on vector and raster data.
2222

2323
The network analysis library provides high level tool for build topology and analysis it.
2424
*/
25+
26+
27+
/** @defgroup server QGIS Server library.*/

python/server/qgsrequesthandler.sip

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class QgsRequestHandler
6161
/**Remove a request parameter*/
6262
virtual int removeParameter( const QString &key ) = 0;
6363
/**Return a request parameter*/
64-
virtual QString parameter( const QString &key ) const = 0;
64+
virtual QString parameter( const QString &key) const = 0;
6565
/**Return the requested format string*/
6666
QString format() const;
6767
/**Return the mime type for the response*/

src/server/qgsrequesthandler.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@ class QDomDocument;
3737
class QImage;
3838
class QgsMapServiceException;
3939

40-
/** This class is an interface hiding the details of reading input and writing output from/to a wms request mechanism.
41-
Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage as a standalone command line executable*/
40+
/**
41+
* \ingroup server
42+
* This class is an interface hiding the details of reading input and writing
43+
* output from/to a wms request mechanism.
44+
* Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage
45+
* as a standalone command line executable
46+
*/
4247
class QgsRequestHandler
4348
{
4449

src/server/qgsserver.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,9 @@ QByteArray QgsServer::handleRequest( const QString queryString ,
590590
{
591591
filtersIterator.value()->responseComplete();
592592
}
593+
// We are done using theRequestHandler in plugins, make sure we don't access
594+
// to a deleted request handler from Python bindings
595+
mServerInterface->clearRequestHandler( );
593596
#endif
594597

595598
theRequestHandler->sendResponse();

src/server/qgsserver.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,26 @@
4141
#endif
4242

4343

44-
/**
44+
/** \ingroup server
4545
* The QgsServer class provides OGC web services.
4646
*/
47-
class SERVER_EXPORT QgsServer
47+
class SERVER_EXPORT QgsServer
4848
{
4949
public:
5050
QgsServer();
5151
~QgsServer();
5252
/** Server initialisation: intialise QGIS ang QT core application.
5353
* This method is automatically called by handleRequest if it wasn't
54-
* explicitly called before */
54+
* explicitly called before
55+
* @note Not available in Python bindings
56+
*/
5557
static bool init( int & argc, char ** argv );
5658
//! The following is mainly for python bindings, that do not pass argc/argv
5759
static bool init();
5860

59-
/** Handle the request. The output is normally printed trough FCGI printf
61+
/** Handles the request. The output is normally printed trough FCGI printf
6062
* by the request handler or, in case the server has been invoked from python
61-
* bindings, a flag is set that capures all the output headers and body, instead
63+
* bindings, a flag is set that captures all the output headers and body, instead
6264
* of printing it returns the output as a QByteArray.
6365
* When calling handleRequest() from python bindings an additional argument
6466
* specify if we only want the headers or the body back, this is mainly useful

src/server/qgsserverfilter.h

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
class QgsServerInterface;
2626

2727
/**
28+
* \ingroup server
2829
* \class QgsServerFilter
2930
* \brief Class defining I/O filters for QGIS Server and
3031
* implemented in plugins.

src/server/qgsserverinterface.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
QgsServerInterface::QgsServerInterface():
2222
mConfigFilePath( QString() )
2323
{
24-
25-
2624
}
2725

2826
QgsServerInterface::~QgsServerInterface()

src/server/qgsserverinterface.h

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qgsserverfilter.h"
2626

2727
/**
28+
* \ingroup server
2829
* QgsServerInterface
2930
* Class defining interfaces exposed by QGIS Server and
3031
* made available to plugins.
@@ -47,6 +48,13 @@ class SERVER_EXPORT QgsServerInterface
4748
*/
4849
virtual void setRequestHandler( QgsRequestHandler* requestHandler ) = 0;
4950

51+
/**
52+
* Clear the request handler
53+
*
54+
* @note not available in python bindings
55+
*/
56+
virtual void clearRequestHandler( ) = 0;
57+
5058
/**
5159
* Get pointer to the capabiblities cache
5260
* @return QgsCapabilitiesCache

src/server/qgsserverinterfaceimpl.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
3838
{
3939
}
4040

41+
42+
void QgsServerInterfaceImpl::clearRequestHandler( )
43+
{
44+
mRequestHandler = NULL;
45+
}
46+
4147
void QgsServerInterfaceImpl::setRequestHandler( QgsRequestHandler * requestHandler )
4248
{
4349
mRequestHandler = requestHandler;

src/server/qgsserverinterfaceimpl.h

+2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ class QgsServerInterfaceImpl : public QgsServerInterface
4545
~QgsServerInterfaceImpl();
4646

4747
void setRequestHandler( QgsRequestHandler* requestHandler ) override;
48+
void clearRequestHandler( ) override;
4849
QgsCapabilitiesCache* capabiblitiesCache() override { return mCapabilitiesCache; }
50+
//! Return the QgsRequestHandler, to be used only in server plugins
4951
QgsRequestHandler* requestHandler( ) override { return mRequestHandler; }
5052
void registerFilter( QgsServerFilter *filter, int priority = 0 ) override;
5153
QgsServerFiltersMap filters( ) override { return mFilters; }

src/server/qgsserverplugins.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,18 @@
2424
// This is needed by SIP otherwise it doesn't find QgsPythonUtils header
2525
class QgsPythonUtils;
2626

27+
/**
28+
* @brief Init Python server plugins and store a list of server plugin names
29+
*/
2730
class SERVER_EXPORT QgsServerPlugins
2831
{
2932
public:
3033
explicit QgsServerPlugins();
3134
/**
32-
* Initialise the python plugins
33-
* @param interface QgsServerInterface
34-
* @return bool true on success
35-
*/
35+
* Initialise the python plugins
36+
* @param interface QgsServerInterface
37+
* @return bool true on success
38+
*/
3639
static bool initPlugins( QgsServerInterface* interface );
3740
//! Pointer to QgsPythonUtils
3841
static QgsPythonUtils* mPythonUtils;

tests/src/python/test_qgsserver.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ def responseComplete(self):
104104
## WMS tests
105105
def wms_request_compare(self, request):
106106
map = self.testdata_path + "testproject.qgs"
107-
response = str(self.server.handleRequest('MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (map, request)))
107+
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (map, request)
108+
response = str(self.server.handleRequest(query_string))
108109
f = open(self.testdata_path + request.lower() + '.txt')
109110
expected = f.read()
110111
f.close()

0 commit comments

Comments
 (0)