<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
<font style="font-size: 10pt;" face="Arial" color="#366092" size="2">Thanks a lot Michel, it worked like a charm. Now I'm getting the whole table as GeoJSON. However I have a doubt about the querying option, for example:<br><br>/fs/boreholes?format=GeoJSON&source__ilike=ODP&queryable=source ---> this source_ilike comes from Ext JS, and should give only the rows in source column with "odp".<br></font><font style="font-size:10pt;" face="Arial" color="#366092" size="2">/fs/boreholes?format=GeoJSON&queryable=source&source=ODP
 ---> this should work as above with FeatureServer </font><font style="" color="#366092"><font style="font-size: 10pt;" size="2"><font style="" face="Arial">but it gives this:<br></font></font></font><pre>An error occurred: string indices must be integers, not str
  File "/var/www/html/mop/fs/web_request/handlers.py", line 230, in cgi
    accepts = accepts )
  File "/var/www/html/mop/fs/FeatureServer/Server.py", line 245, in dispatchRequest
    result = method(action)
  File "/var/www/html/mop/fs/FeatureServer/DataSource/GeoAlchemy.py", line 160, in select
    for k, v in action.attributes.iteritems()]


{'source': 'ODP', 'queryable': 'source', 'format': 'GeoJSON'}
</pre><br id="FontBreak"><font style="font-size: 10pt;" face="Arial" color="#366092" size="2">Because I'm using Ext JS to do the search (search button), I'd like this form: /fs/boreholes?format=GeoJSON&source__ilike=ODP&queryable=source, could it be possible to adapt this in FeatureServer?<br><br>Thanks again,<br><br>Gery<br><br>PS: this is the error coming from the Ext JS example above:<br></font><pre>An error occurred: 'str' object has no attribute 'query_action_types'
  File "/var/www/html/mop/fs/web_request/handlers.py", line 230, in cgi
    accepts = accepts )
  File "/var/www/html/mop/fs/FeatureServer/Server.py", line 207, in dispatchRequest
    request.parse(params, path_info, host, post_data, request_method)
  File "/var/www/html/mop/fs/FeatureServer/Service/GeoJSON.py", line 44, in parse
    Request.parse(self, params, path_info, host, post_data, request_method, format_obj=g)
  File "/var/www/html/mop/fs/FeatureServer/Service/Request.py", line 70, in parse
    action = self.get_select_action(path_info, params)
  File "/var/www/html/mop/fs/FeatureServer/Service/Request.py", line 145, in get_select_action
    if type in ds.query_action_types:


{'source__ilike': 'ODP', 'queryable': 'source', 'format': 'GeoJSON'}
</pre><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br>__________________________________________________________________________________________<br>Piensa en el medio ambie<font style="" face="Arial">nte - mantenlo en la pantalla. NO lo imprimas si NO es necesario.</font></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2">Think green - keep it on the screen. Do NOT print if it is NOT necessary.</font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><span id="ecxresult_box" class="ecxshort_text" lang="de"><span class="ecxhps">Denken Sie an</span> <span class="ecxhps">die Umwelt</span></span></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><span id="ecxresult_box" lang="de"><span class="ecxhps"></span> <span class="ecxhps">-</span> <span class="ecxhps">bewahren Sie es</span> <span class="ecxhps">auf dem Bildschirm.</span> <span class="ecxhps">Drucken Sie NICHT</span><span>, wenn</span> <span class="ecxhps">es NICHT notwendig ist</span><span>.</span></span></font><br><br><br><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">Subject: Re: [FeatureServer] GeoAlchemy, what is the trick?<br>From: iocast@me.com<br>Date: Wed, 5 Dec 2012 08:34:15 +0100<br>CC: featureserver@lists.osgeo.org<br>To: gamejihou@hotmail.com<br><br><div><div>Hi Gery</div><div><br></div><div>In the test files I found an example and tried to adapt it:</div><div><br></div><div>The config entry I changed as follow:</div><div>************************</div><div><div>[boreholes]</div><div>type=GeoAlchemy</div><div>dburi=postgresql://<user>:<password>@localhost:5432/map</div><div>model=model.boreholes_model</div><div>cls=Boreholes</div><div>fid=id</div><div>geometry=geom</div></div><div><div>************************</div><div></div></div><div>where the <b>model</b> is a subdirectory of the featureserver root directory and boreholes_model is a file called boreholes_model.py. I also added a __init__.py file in the model folder to be sure that it is recognised as a Python package.</div><div><b>cls</b> is the class name of your model, so it should be Boreholes.</div><div><br></div><div>You could also look at the 'Road' example in the folder tests</div><div><ul class="ecxMailOutline"><li>DataSource.GeoAlchemy.txt and</li><li>geoalchemy_model.py for the model declaration</li></ul></div><div><br></div><div>Hopefully it would help</div><div>Michel</div></div><div><br></div><div><br></div><div><br></div><br><div><div>On Dec 5, 2012, at 8:00 AM, Iocast <<a href="mailto:iocast@me.com">iocast@me.com</a>> wrote:</div><br class="ecxApple-interchange-newline"><blockquote><div style="word-wrap:break-word"><div>Hi Gery</div><div><br></div><div>I never tried/changed the GeoAlchemy data source, however I'm going to try your setup and have a look if I get the same error.</div><div><br></div><div>Cheers,</div><div>Michel</div><div><br></div><div><br></div><div><blockquote><font style="font-size:10pt" face="Arial" color="#366092" size="2">I get this error recently, I'm not sure why, someone has an idea? thanks<br><br></font><pre style="font-size:13px">An error occurred: 'NoneType' object has no attribute 'items'
  File "/var/www/html/mop/fs/web_request/handlers.py", line 236, in cgi
    for (key, value) in returned_data[2].items():


{}</pre></blockquote><div><br></div></div><div><br></div><div><br></div><br><div><div>On Dec 4, 2012, at 10:31 AM, Gery . <<a href="mailto:gamejihou@hotmail.com">gamejihou@hotmail.com</a>> wrote:</div><br class="ecxApple-interchange-newline"><blockquote><div class="ecxhmmessage" style="font-size:10pt;font-family:Tahoma;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;orphans:2;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;widows:2;word-spacing:0px"><div dir="ltr"><font style="font-size:10pt" face="Arial" color="#366092" size="2">Hello,<br><br>I'm using GeoAlchemy with FeatureServer, but I'm new using both, so sorry for the very simple questions. This is my model (boreholes.model) for one of my PostGis tables:<br><br>*****************************<br>print "Content-type: text/html\n\n";<br><br>from sqlalchemy import *<br>from sqlalchemy.orm import *<br>from sqlalchemy.dialects.postgresql import *<br>from geoalchemy import *<br>from geoalchemy.postgis import *<br><br>engine = create_engine('<a target="_blank">postgresql://postgres:pass@localhost:5432/map'</a>, echo=False)<br>metadata = MetaData(engine)<br><br>session = sessionmaker(bind=engine)()<br><br>boreholes_table = Table('boreholes_point_wgs84', metadata,<br>                        Column('id', SMALLINT, primary_key=True),<br>                        Column('fid', SMALLINT),<br>                        Column('longitude', DOUBLE_PRECISION),<br>                        Column('latitude', DOUBLE_PRECISION),<br>                        Column('w_depth_m', DOUBLE_PRECISION),<br>                        Column('station', VARCHAR(150)),<br>                        Column('type', VARCHAR(150)),<br>                        Column('survey', VARCHAR(150)),<br>                        Column('source', VARCHAR(150)),<br>                        Column('max_pen_m', VARCHAR(150)),<br>                        Column('core_rec_m', VARCHAR(150)),<br>                        Column('t_g_ckm1', VARCHAR(150)),<br>                        Column('h_f_mwm2', VARCHAR(150)),<br>                        Column('comments', TEXT),<br>                        GeometryExtensionColumn('geom', Geometry(3)))<br><br>class Boreholes(object):<br>    def __init__ (self, id, fid, longitude, latitude, w_depth_m, station, type, survey, source, max_pen_m, core_rec_m, t_g_ckm1, h_f_mwm2, comments):<br>        self.id = id<br>        self.fid = fid<br>        self.longitude = longitude<br>        self.latitude = latitude<br>        self.w_depth_m = w_depth_m<br>        self.station = station<br>        self.type = type<br>        self.survey = survey<br>        self.source = source<br>        self.max_pen_m = max_pen_m<br>        self.core_rec_m = core_rec_m<br>        self.t_g_ckm1 = t_g_ckm1<br>        self.h_f_mwm2 = h_f_mwm2<br>        self.comments = comments<br><br>mapper(Boreholes, boreholes_table,<br>       properties={<br>                 'geom': GeometryColumn(boreholes_table.c.geom,<br>                                        comparator=PGComparator)<br>                  })<br><br>GeometryDDL(boreholes_table)<br><br></font><font style="font-size:10pt" face="Arial" color="#366092" size="2">*****************************</font><br><font style="font-size:10pt" face="Arial" color="#366092" size="2"><br>and this is what I have in my featureserver.cfg:<br><br></font><font style="font-size:10pt" face="Arial" color="#366092" size="2">*****************************<br>[boreholes]<br>type=GeoAlchemy<br>dburi=<a target="_blank">postgresql://postgres:pass@localhost:5432/map</a><br>model=../model/boreholes.model<br>cls=boreholes_point_wgs84<br>fid=id<br>geometry=geom<br></font><font style="font-size:10pt" face="Arial" color="#366092" size="2">*****************************</font><br><font style="font-size:10pt" face="Arial" color="#366092" size="2"><br>so what I want is to query this table and output that in GeoJSON format. I'm doing the query in OpenLayers using GeoExt like this:<br><br></font><font style="font-size:10pt" face="Arial" color="#366092" size="2">*****************************</font><br><font style="font-size:10pt" face="Arial" color="#366092" size="2">var searchformPanel = new GeoExt.form.FormPanel(<br>        {<br>            width: 250,<br>            bodyStyle: 'padding:5px',<br>            labelAlign: 'top',<br>            defaults:<br>            {<br>                anchor: '100%'<br>            },<br>            protocol: new OpenLayers.Protocol.HTTP(<br>            {<br>                url: '<a href="http://www.mop.org/fs/boreholes?format=GeoJSON%27" target="_blank">http://www.mop.org/fs/boreholes?format=GeoJSON'</a>,<br>                format: new OpenLayers.Format.GeoJSON(<br>                {<br>                    ignoreExtraDims: true,<br>                    'internalProjection': new OpenLayers.Projection("EPSG:900913"),<br>                    'externalProjection': new OpenLayers.Projection("EPSG:4326")<br>                }<br>                )<br>            }<br>            ),<br>            items:<br>            [<br>            {<br>                xtype: 'textfield',<br>                name: 'station__like',<br>                fieldLabel: 'Enter a word',<br>                allowBlank: false<br>            }<br>            ],<br>...<br>...<br></font><font style="font-size:10pt" face="Arial" color="#366092" size="2">*****************************</font><br><font style="font-size:10pt" face="Arial" color="#366092" size="2"><br>by the way, this PostGis table is served by MarServer as WMS, but I think this has nothing to do with the query. So, to do this query I'm sure I need something else related to GeoAlchemy and featureserver itself but not sure what it is, I'd be grateful for some support on this, thanks in advance for any help.<br><br>Best regards,<br><br>Gery<br> <br id="ecxFontBreak"></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br>__________________________________________________________________________________________<br>Piensa en el medio ambie<font face="Arial">nte - mantenlo en la pantalla. NO lo imprimas si NO es necesario.</font></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2">Think green - keep it on the screen. Do NOT print if it is NOT necessary.</font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><br></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><span id="ecxresult_box" class="ecxshort_text" lang="de"><span class="ecxhps">Denken Sie an</span><span class="ecxApple-converted-space"> </span><span class="ecxhps">die Umwelt</span></span></font><font style="font-size:10pt" face="Arial" color="#1F497D" size="2"><span id="ecxresult_box" lang="de"><span class="ecxhps"></span> <span class="ecxhps">-</span><span class="ecxApple-converted-space"> </span><span class="ecxhps">bewahren Sie es</span><span class="ecxApple-converted-space"> </span><span class="ecxhps">auf dem Bildschirm.</span><span class="ecxApple-converted-space"> </span><span class="ecxhps">Drucken Sie NICHT</span><span>, wenn</span><span class="ecxApple-converted-space"> </span><span class="ecxhps">es NICHT notwendig ist</span><span>.</span></span></font><br></div>_______________________________________________<br>FeatureServer mailing list<br><a href="mailto:FeatureServer@lists.osgeo.org">FeatureServer@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/featureserver" target="_blank">http://lists.osgeo.org/mailman/listinfo/featureserver</a><br></div></blockquote></div><br></div>_______________________________________________<br>FeatureServer mailing list<br><a href="mailto:FeatureServer@lists.osgeo.org">FeatureServer@lists.osgeo.org</a><br>http://lists.osgeo.org/mailman/listinfo/featureserver<br></blockquote></div><br></div>                                          </div></body>
</html>