QGIS Web Client's WSGI search requires you to configure your Apache into executing wsgi scripts. Firstly you'll need to install the correct module (When downloading a wsgi module please be sure to check the correct Apache version).
On the windows OS the configuration file can be found in the folder OSGeo4W/apache/conf/httpd.conf
Enable your module:
LoadModule wsgi_module modules/mod_wsgi.so
Now within the file OSGeo4W/httpd.d/httpd_qgis.conf we will configure our qgis application. This folder can contain definitions for qgis or any other kind of applications.
We will be adding 2 definitions, first one is the alias for wsgi:
Alias /wsgi/ C:\OSGeo4W/wsgi/ #**NOTE
#This will allow to change the path of the wsgi folder (which contains your wsgi/python scripts) to a shorter one -> /wsgi/
The second one is how and where we handle/execute these scripts:
<Directory "C:\OSGeo4W/wsgi/">
SetHandler wsgi-script
Options ExecCGI
Order allow,deny
Allow from all
</Directory>
**NOTE I've moved the wsgi scripts and the qgiswebclient/wsgi folder because the qwc_connect.py contains a database string, which is information I wouldn't like to share with the people using my Apache server
After these simple steps the Apache should reboot. If the Apache successfully rebooted the wsgi scripts are now supported.
The next step is setting up the wsgi scripts inside the /wsgi folder.
In the file qwc_connect.py, we will now need to set up our database string:
DB_CONN_STRING="host='hostname' dbname='DATABASE_NAME' port='5432' user='myuser' password='mypassword'"
After we got our database string set, it is time to set the searchtables within the file search.wsgi, where we jump to line 32 and set:
searchtables = [sheme_name.table_name,...];
Now that we have our searchtable names set, we should define the views inside our database. Here is an example of create view script for PostgreSQL from michele's table:
CREATE OR REPLACE VIEW view_name_here AS --if you're using pgAdmin, remove this line
SELECT
concat ('Layer catasto_terreni: ', c.id,'-', c.foglio, '\', c.part_cat, ' ', c.comune) AS displaytext,
--this is the display text in your search box
concat(c.id,'\', c.foglio,'\', c.part_cat, '\', c.comune) AS search_category,
concat(c.part_cat, '/', c.foglio, '/', c.comune) AS searchstring,
--we perform searching by entering values parc_cat/foglio/comune, we can concat them to form more even complex strings, but I use a different view for each "type" of search
concat('') AS showlayer,
c.geom AS the_geom --this field is the most important one since it will zoom to this geometry
FROM catasto_terreni c;
This is an example of a search: