[Featureserver] Can't adapt error

Yves Moisan yves.moisan at boreal-is.com
Wed Aug 26 17:11:06 EDT 2009


> Hi All,
> 
> I have a nagging error when I query FS in mod_python :
> 
> http://localhost:8080/featureserver/featureserver.py/af_parcel?queryable=field1&field1=16
> 
> An error occurred: can't adapt
>   File "C:\ms4w\Apache\htdocs\featureserver\web_request\handlers.py",
> line 65, in mod_python
>     accepts = accepts )
>   File "C:\ms4w\Apache\htdocs\featureserver\FeatureServer\Server.py",
> line 161, in dispatchRequest
>     result = method(action)
>   File "C:\ms4w\Apache\htdocs\featureserver\FeatureServer\DataSource
> \PostGIS.py", line 177, in select
>     cursor.execute(str(sql), attrs)
> 
> The CGI version works a treat :
> http://localhost:8080/featureserver/featureserver.cgi/af_parcel?queryable=field1&field1=16
> 
> Also http://localhost:8080/featureserver/featureserver.py/af_parcel
> works fine.
> 
> I found a couple of references to the "Can't adapt error" pointing to
> Django forums where there was a mention that psycopg2 might be at fault,
> but if featureserver.cgi works then that means psycopg2 works since
> postgis.py imports it.  I'm on windows and mod_python 3.3.1.  Anyone
> with a similar issue ?

Someone from StickPeople suggested this :

" ...It sounds like 
modpython is passing information to psycopg that is not a standard type 
(aka string or integer), and therefor psycopg2 doesn't know how to
parse 
it into exec string.  You could try the following in your modpytyhon 
handler, which might fix it (a snippit I found on the web at
http://www.modpython.org/pipermail/mod_python/2005-December/019714.html
):


import psycopg2
import psycopg2.extras
import psycopg2.extensions
import mod_python
psycopg2.extensions.register_adapter(mod_python.util.StringField,   \
       psycopg2.extensions.QuotedString)

I tried plunking that into PostGIS.py to no avail.  A more clueful
Python programmer could probably use that info in a better way.

Yves





More information about the Featureserver mailing list