Flex API, XML API modules are they needed?
Hey all, I work for The Evergreen State College a small liberal arts college in Olympia, WA USA. We're using Drupal as a portal system connected to our student information system, and also as a community networking tool centered around governance activities. I also have a side job developing assessment analysis software (for public school systems) using flex, php and postgres. For the last two years + we've been developing home grown Flex applications that use REST XML web services, as well as drupal modules that consume the same web services. This has become the primary architecture for developing applications at our campus. For those who don't know me, I'm also the maintainer of the CAS (Single sign on for universities) and Form Defaults modules. I'm trying to decide whether to take the time to push out new modules associated with the way we do development, or whether people would rather just use existing frameworks. My question is, which if any of the following apis/modules might be of interest to the community? Here's a summary of what's been developed so far: Flex-api: A quick way to leverage FLEX applications in Drupal. The FLEX applications currently get embedded in a page, but we're thinking of extending this to blocks as well. The generated code tells the flex app what url it should use as a web service, so that it can get data. When the data service gets called it looks for a class file includes it an allows only methods of that class to be called. It also looks for an auth method to see if the flex app is allowed. Anyway, it's a nice way to bundle flex/flash applications with modules. XML Forms Binding: This api uses SimpleXML and php DOM apis to convert XML to drupal form_values style arrays so that you can basically get data from a web service and make a form using (tree=true) that will directly edit the XML that was passed to you provided you sprinkle a couple of functions in your form functions and submit handlers. Includes conversion API for converting nested arrays (like forms) into XML and back. XML-enabled DB Binding: Write sql binding syntax that looks like SELECT * from table where name={xpathtofield}. The XPATH entry can also be an index to a field array. I find this more intuitive than the %1, %2 ,etc syntax that's used in drupal, cause you can reference the same bind variable more than once in an SQL statement. Are these to specific to my way of doing development or are they drupal.org worthy. Really I'm ok either way, (got plenty of work to do) so don't feel like you need to encourage me if you aren't interested in using it. Dave
My question is, which if any of the following apis/modules might be
XML Forms Binding: This api uses SimpleXML and php DOM apis to convert XML to drupal form_values style arrays so that you can basically get data from a web service and make a form using (tree=true) that will directly edit the XML that was passed to you provided you sprinkle a couple of functions in your form functions and submit handlers. Includes conversion API for converting nested arrays (like forms) into XML and back.
I like this one. -- Morbus Iff ( notice how he deftly sidesteps the panty issue. ) Technical: http://www.oreillynet.com/pub/au/779 Enjoy: http://www.disobey.com/ and http://www.videounderbelly.com/ aim: akaMorbus / skype: morbusiff / icq: 2927491 / jabber.org: morbus
On Mon, 2009-02-09 at 07:21 -0500, Morbus Iff wrote:
My question is, which if any of the following apis/modules might be
XML Forms Binding: This api uses SimpleXML and php DOM apis to convert XML to drupal form_values style arrays so that you can basically get data from a web service and make a form using (tree=true) that will directly edit the XML that was passed to you provided you sprinkle a couple of functions in your form functions and submit handlers. Includes conversion API for converting nested arrays (like forms) into XML and back.
I like this one.
Same here.
On 9-Feb-09, at 12:40 AM, David Metzler wrote:
XML-enabled DB Binding: Write sql binding syntax that looks like SELECT * from table where name={xpathtofield}. The XPATH entry can also be an index to a field array. I find this more intuitive than the %1, %2 ,etc syntax that's used in drupal, cause you can reference the same bind variable more than once in an SQL statement.
I believe this is solved in DB:TNG, now in Drupal 7. Calls to db_query() now have array keys, which can be used instead of the traditional ordered placeholders. http://api.drupal.org/api/function/db_query/7 --Andrew
On Mon, 9 Feb 2009 12:16:12 -0500, Andrew Berry <andrewberry@sentex.net> wrote:
On 9-Feb-09, at 12:40 AM, David Metzler wrote:
XML-enabled DB Binding: Write sql binding syntax that looks like SELECT * from table where name={xpathtofield}. The XPATH entry can also be an index to a field array. I find this more intuitive than the %1, %2 ,etc syntax that's used in drupal, cause you can reference the same bind variable more than once in an SQL statement.
I believe this is solved in DB:TNG, now in Drupal 7. Calls to db_query() now have array keys, which can be used instead of the traditional ordered placeholders.
http://api.drupal.org/api/function/db_query/7
--Andrew
That's a different question, I think. DBTNG uses arrays and named placeholders. It sounds like David is talking about XPath based queries, which are another animal entirely and not DB portable. David, can you elaborate here? DBTNG does not allow the reuse of placeholders within the same query, because PDO doesn't either. --Larry Garfield
On Mon, Feb 9, 2009 at 2:00 PM, Larry Garfield <larry@garfieldtech.com> wrote:
That's a different question, I think. DBTNG uses arrays and named placeholders. It sounds like David is talking about XPath based queries, which are another animal entirely and not DB portable. David, can you elaborate here?
DBTNG does not allow the reuse of placeholders within the same query, because PDO doesn't either.
--Larry Garfield
Well technically only certain versions of the PDO don't allow it: http://paul-m-jones.com/?p=243 I can't find the php.net issue for this but I seem to remember that the change was eventually reverted leaving a band of versions that don't allow it. andrew
The article alludes to a security issue. Anyone know what it is? I get the stability concerns, which is why I coded in an extra layer at my end. The SQL statements get rewritten into a numeric variable bind syntax before passing to the db layer in my implementation for just this reason. A band of versions that include php 5.2.2 might be fatal to that idea :). If this makes it in it sounds like it should be part of an XML specific db wrapper, but it sure doesn't sound like it make sense to focus my energies there. Dave On Feb 10, 2009, at 12:23 PM, andrew morton wrote:
On Mon, Feb 9, 2009 at 2:00 PM, Larry Garfield <larry@garfieldtech.com> wrote:
That's a different question, I think. DBTNG uses arrays and named placeholders. It sounds like David is talking about XPath based queries, which are another animal entirely and not DB portable. David, can you elaborate here?
DBTNG does not allow the reuse of placeholders within the same query, because PDO doesn't either.
--Larry Garfield
Well technically only certain versions of the PDO don't allow it: http://paul-m-jones.com/?p=243
I can't find the php.net issue for this but I seem to remember that the change was eventually reverted leaving a band of versions that don't allow it.
andrew
Actually not quite, in it's simplest form a key into an associative array and a xpath into a simpleXML object are achieving the same goal. $xml_row->xpath('column_name') $array_row['column_name'] All I did was make my binding layer work with either, so you could pass an associative array OR a parsed SimpleXML object into the db_query call as the parameter set. Since I used a bracketed syntax rather than one like %d, I did a simple thing of saying if is_object ($parms) then assume its xml and call an xpath method returning the first value to get the string replacement.
DBTNG does not allow the reuse of placeholders within the same query, because PDO doesn't either.
This was a primary concern for me. I still haven't figured out why database drivers never do this....? It seems so straightforward to think of parameters as key value pairs. What I did here was to rewrite the parameters array into one that was numerically based because hey the postgres driver needed numerical bind arguments. I just got tired of hand rolling arrays arrays as parameters when I had a perfectly good $form_values array or simplexml object to use as the parameter source. If DBTNG allows extra parameters to be passed that don't get used in the query then it's probably close enough for what most people need, and the XML to array conversion api would get you the rest of the way there anyway. Anyway thus far what I'm hearing is the xml_to_array conversion utility is the most desirable. And I haven't heard of anyone talking much Flex. At one point Dries seemed pretty interested (back in 2007) but I haven't heard much recently on this front. Does that make things clearer? Dave On Feb 9, 2009, at 2:00 PM, Larry Garfield wrote:
On Mon, 9 Feb 2009 12:16:12 -0500, Andrew Berry <andrewberry@sentex.net> wrote:
On 9-Feb-09, at 12:40 AM, David Metzler wrote:
XML-enabled DB Binding: Write sql binding syntax that looks like SELECT * from table where name={xpathtofield}. The XPATH entry can also be an index to a field array. I find this more intuitive than the %1, %2 ,etc syntax that's used in drupal, cause you can reference the same bind variable more than once in an SQL statement.
I believe this is solved in DB:TNG, now in Drupal 7. Calls to db_query() now have array keys, which can be used instead of the traditional ordered placeholders.
http://api.drupal.org/api/function/db_query/7
--Andrew
That's a different question, I think. DBTNG uses arrays and named placeholders. It sounds like David is talking about XPath based queries, which are another animal entirely and not DB portable. David, can you elaborate here?
DBTNG does not allow the reuse of placeholders within the same query, because PDO doesn't either.
--Larry Garfield
On Tuesday 10 February 2009 9:22:26 pm David Metzler wrote:
This was a primary concern for me. I still haven't figured out why database drivers never do this....? It seems so straightforward to think of parameters as key value pairs. What I did here was to rewrite the parameters array into one that was numerically based because hey the postgres driver needed numerical bind arguments. I just got tired of hand rolling arrays arrays as parameters when I had a perfectly good $form_values array or simplexml object to use as the parameter source.
If DBTNG allows extra parameters to be passed that don't get used in the query then it's probably close enough for what most people need, and the XML to array conversion api would get you the rest of the way there anyway.
PDO gets cranky if your argument count does not exactly match your placeholder count. DBTNG doesn't do any extra checking on top of that for you, so yes you do need to make sure you pass in only those values that you need and nothing else. Some databases support reusing placeholders. Some do not. Who knows why; database vendors are silly people. PDO has gone back and forth on whether it tries to emulate reuse on databases that don't natively support it or not (a process that was frequently buggy, according to PDO's principal author, Wez Furlong), creating a situation where unless you know your precise version down to the .z level you can't reliably assume that it's going to work. So we assume that you can't reuse placeholders. Any XML-to-array conversion should happen outside the DB layer, IMO. -- Larry Garfield larry@garfieldtech.com
participants (6)
-
Andrew Berry -
andrew morton -
Athanasios Velios -
David Metzler -
Larry Garfield -
Morbus Iff