{"action":"opened","issue":{"url":"https://api.github.com/repos/mapnik/mapnik/issues/2738","labels_url":"https://api.github.com/repos/mapnik/mapnik/issues/2738/labels{/name}","comments_url":"https://api.github.com/repos/mapnik/mapnik/issues/2738/comments","events_url":"https://api.github.com/repos/mapnik/mapnik/issues/2738/events","html_url":"https://github.com/mapnik/mapnik/issues/2738","id":63743621,"number":2738,"title":"Custom parameters for XML files","user":{"login":"srounet","id":194602,"avatar_url":"https://avatars.githubusercontent.com/u/194602?v=3","gravatar_id":"","url":"https://api.github.com/users/srounet","html_url":"https://github.com/srounet","followers_url":"https://api.github.com/users/srounet/followers","following_url":"https://api.github.com/users/srounet/following{/other_user}","gists_url":"https://api.github.com/users/srounet/gists{/gist_id}","starred_url":"https://api.github.com/users/srounet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srounet/subscriptions","organizations_url":"https://api.github.com/users/srounet/orgs","repos_url":"https://api.github.com/users/srounet/repos","events_url":"https://api.github.com/users/srounet/events{/privacy}","received_events_url":"https://api.github.com/users/srounet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-03-23T14:56:18Z","updated_at":"2015-03-23T14:56:18Z","closed_at":null,"body":"Is it possible for a **postgis** datasource to have SQL queries with **external parameters**?\r\n\r\nSo for example:\r\n\r\n```xml\r\n<Datasource>\r\n   <Parameter name=\"table\">\r\n      <![CDATA[(select id, geom FROM my_geometries where c_id =12345) as foo]]>\r\n   </Parameter>\r\n   ...\r\n</Datasource>\r\n```\r\nwould become\r\n\r\n```xml\r\n<Datasource>\r\n    ...\r\n   <Parameter name=\"table\">\r\n      <![CDATA[(select id, geom FROM my_geometries where c_id = %(c_id)s) as foo]]>\r\n   </Parameter>\r\n   ...\r\n</Datasource>\r\n```\r\n\r\nTo give a bit more context, I'm trying to move from mapserver to mapnik and as for now I'm using mapserver that way:\r\n\r\n1. You have an url where you can add parameters like that: **http://localhost/map/z/x/y.png?c_id=12345**\r\n2. Into mapserver layer configurations you can grab those arguments and inject them into the sql query that way:\r\n```\r\nDATA \"geom FROM (\r\n   SELECT id, geom\r\n   FROM my_geometries\r\n   WHERE c_id = '%c_id%'\r\n) as foo using unique id using SRID=4326\"\r\n```\r\n\r\nOfc, there are all the stuff around SQL injection etc that mytilecache/mapserver takes care for you, but for the big picture it's like that.\r\n\r\nTo reformulate my objective here, let's say I have Mapnik + TileStache and I want to control the way some of my layers do generate tiles using custom URL parameters.\r\n\r\nAs for now, it seems that it's not possible and not even into the Mapnik roadmap, it also seems that it's not even an objective for Mapnik to act like that, and if it's the case I understand (the goal here is different).\r\n\r\nBut maybe there is a solution for this particular case into custom plugins ?\r\nI've seen that one can write a Plugin using let's say Python Bindings, and maybe implement such a thing."}}