Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2206 from elpaso/server-docs-server-iface-fix
[SERVER] Server docs and server iface fix
  • Loading branch information
elpaso committed Jul 10, 2015
2 parents 2b5ea36 + 0312dbf commit d7d5977
Show file tree
Hide file tree
Showing 12 changed files with 47 additions and 15 deletions.
3 changes: 3 additions & 0 deletions doc/modules.dox
Expand Up @@ -22,3 +22,6 @@ high level tools for carrying out spatial analysis on vector and raster data.

The network analysis library provides high level tool for build topology and analysis it.
*/


/** @defgroup server QGIS Server library.*/
2 changes: 1 addition & 1 deletion python/server/qgsrequesthandler.sip
Expand Up @@ -61,7 +61,7 @@ class QgsRequestHandler
/**Remove a request parameter*/
virtual int removeParameter( const QString &key ) = 0;
/**Return a request parameter*/
virtual QString parameter( const QString &key ) const = 0;
virtual QString parameter( const QString &key) const = 0;
/**Return the requested format string*/
QString format() const;
/**Return the mime type for the response*/
Expand Down
9 changes: 7 additions & 2 deletions src/server/qgsrequesthandler.h
Expand Up @@ -37,8 +37,13 @@ class QDomDocument;
class QImage;
class QgsMapServiceException;

/** This class is an interface hiding the details of reading input and writing output from/to a wms request mechanism.
Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage as a standalone command line executable*/
/**
* \ingroup server
* This class is an interface hiding the details of reading input and writing
* output from/to a wms request mechanism.
* Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage
* as a standalone command line executable
*/
class QgsRequestHandler
{

Expand Down
3 changes: 3 additions & 0 deletions src/server/qgsserver.cpp
Expand Up @@ -590,6 +590,9 @@ QByteArray QgsServer::handleRequest( const QString queryString ,
{
filtersIterator.value()->responseComplete();
}
// We are done using theRequestHandler in plugins, make sure we don't access
// to a deleted request handler from Python bindings
mServerInterface->clearRequestHandler( );
#endif

theRequestHandler->sendResponse();
Expand Down
12 changes: 7 additions & 5 deletions src/server/qgsserver.h
Expand Up @@ -41,24 +41,26 @@
#endif


/**
/** \ingroup server
* The QgsServer class provides OGC web services.
*/
class SERVER_EXPORT QgsServer
class SERVER_EXPORT QgsServer
{
public:
QgsServer();
~QgsServer();
/** Server initialisation: intialise QGIS ang QT core application.
* This method is automatically called by handleRequest if it wasn't
* explicitly called before */
* explicitly called before
* @note Not available in Python bindings
*/
static bool init( int & argc, char ** argv );
//! The following is mainly for python bindings, that do not pass argc/argv
static bool init();

/** Handle the request. The output is normally printed trough FCGI printf
/** Handles the request. The output is normally printed trough FCGI printf
* by the request handler or, in case the server has been invoked from python
* bindings, a flag is set that capures all the output headers and body, instead
* bindings, a flag is set that captures all the output headers and body, instead
* of printing it returns the output as a QByteArray.
* When calling handleRequest() from python bindings an additional argument
* specify if we only want the headers or the body back, this is mainly useful
Expand Down
1 change: 1 addition & 0 deletions src/server/qgsserverfilter.h
Expand Up @@ -25,6 +25,7 @@
class QgsServerInterface;

/**
* \ingroup server
* \class QgsServerFilter
* \brief Class defining I/O filters for QGIS Server and
* implemented in plugins.
Expand Down
2 changes: 0 additions & 2 deletions src/server/qgsserverinterface.cpp
Expand Up @@ -21,8 +21,6 @@
QgsServerInterface::QgsServerInterface():
mConfigFilePath( QString() )
{


}

QgsServerInterface::~QgsServerInterface()
Expand Down
8 changes: 8 additions & 0 deletions src/server/qgsserverinterface.h
Expand Up @@ -25,6 +25,7 @@
#include "qgsserverfilter.h"

/**
* \ingroup server
* QgsServerInterface
* Class defining interfaces exposed by QGIS Server and
* made available to plugins.
Expand All @@ -47,6 +48,13 @@ class SERVER_EXPORT QgsServerInterface
*/
virtual void setRequestHandler( QgsRequestHandler* requestHandler ) = 0;

/**
* Clear the request handler
*
* @note not available in python bindings
*/
virtual void clearRequestHandler( ) = 0;

/**
* Get pointer to the capabiblities cache
* @return QgsCapabilitiesCache
Expand Down
6 changes: 6 additions & 0 deletions src/server/qgsserverinterfaceimpl.cpp
Expand Up @@ -38,6 +38,12 @@ QgsServerInterfaceImpl::~QgsServerInterfaceImpl()
{
}


void QgsServerInterfaceImpl::clearRequestHandler( )
{
mRequestHandler = NULL;
}

void QgsServerInterfaceImpl::setRequestHandler( QgsRequestHandler * requestHandler )
{
mRequestHandler = requestHandler;
Expand Down
2 changes: 2 additions & 0 deletions src/server/qgsserverinterfaceimpl.h
Expand Up @@ -45,7 +45,9 @@ class QgsServerInterfaceImpl : public QgsServerInterface
~QgsServerInterfaceImpl();

void setRequestHandler( QgsRequestHandler* requestHandler ) override;
void clearRequestHandler( ) override;
QgsCapabilitiesCache* capabiblitiesCache() override { return mCapabilitiesCache; }
//! Return the QgsRequestHandler, to be used only in server plugins
QgsRequestHandler* requestHandler( ) override { return mRequestHandler; }
void registerFilter( QgsServerFilter *filter, int priority = 0 ) override;
QgsServerFiltersMap filters( ) override { return mFilters; }
Expand Down
11 changes: 7 additions & 4 deletions src/server/qgsserverplugins.h
Expand Up @@ -24,15 +24,18 @@
// This is needed by SIP otherwise it doesn't find QgsPythonUtils header
class QgsPythonUtils;

/**
* @brief Init Python server plugins and store a list of server plugin names
*/
class SERVER_EXPORT QgsServerPlugins
{
public:
explicit QgsServerPlugins();
/**
* Initialise the python plugins
* @param interface QgsServerInterface
* @return bool true on success
*/
* Initialise the python plugins
* @param interface QgsServerInterface
* @return bool true on success
*/
static bool initPlugins( QgsServerInterface* interface );
//! Pointer to QgsPythonUtils
static QgsPythonUtils* mPythonUtils;
Expand Down
3 changes: 2 additions & 1 deletion tests/src/python/test_qgsserver.py
Expand Up @@ -104,7 +104,8 @@ def responseComplete(self):
## WMS tests
def wms_request_compare(self, request):
map = self.testdata_path + "testproject.qgs"
response = str(self.server.handleRequest('MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (map, request)))
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (map, request)
response = str(self.server.handleRequest(query_string))
f = open(self.testdata_path + request.lower() + '.txt')
expected = f.read()
f.close()
Expand Down

0 comments on commit d7d5977

Please sign in to comment.