From 2768539bfe2bf8f2d370fcef03ae7f15b55e0579 Mon Sep 17 00:00:00 2001
From: Ryan Williams <rdw@lindenlab.com>
Date: Wed, 8 Apr 2009 22:39:01 +0000
Subject: [PATCH] svn merge -r116334:116916
 svn+ssh://svn.lindenlab.com/svn/linden/branches/rad-chilies/rad-chilies-trunkmerge-2

---
 indra/lib/python/indra/ipc/servicebuilder.py  |  6 +--
 .../python/indra/util/fastest_elementtree.py  |  1 -
 indra/lib/python/indra/util/named_query.py    | 42 ++++++++++++-------
 indra/llinventory/lltransactiontypes.h        |  1 +
 4 files changed, 32 insertions(+), 18 deletions(-)

diff --git a/indra/lib/python/indra/ipc/servicebuilder.py b/indra/lib/python/indra/ipc/servicebuilder.py
index 04ccee76576..cb43bcb26fb 100644
--- a/indra/lib/python/indra/ipc/servicebuilder.py
+++ b/indra/lib/python/indra/ipc/servicebuilder.py
@@ -108,7 +108,7 @@ def on_in(query_name, host_key, schema_key):
     @param schema_key Logical name of destination schema.  Will
         be looked up in indra.xml.
     """
-    host_name = config.get(host_key)
-    schema_name = config.get(schema_key)
-    return '/'.join( ('on', host_name, 'in', schema_name, query_name.lstrip('/')) )
+    return "on/config:%s/in/config:%s/%s" % (host_key.strip('/'),
+                                             schema_key.strip('/'),
+                                             query_name.lstrip('/'))
 
diff --git a/indra/lib/python/indra/util/fastest_elementtree.py b/indra/lib/python/indra/util/fastest_elementtree.py
index 3e2189c4e7f..4fcf662dd90 100644
--- a/indra/lib/python/indra/util/fastest_elementtree.py
+++ b/indra/lib/python/indra/util/fastest_elementtree.py
@@ -36,7 +36,6 @@
 
 # Using cElementTree might cause some unforeseen problems, so here's a
 # convenient off switch.
-
 use_celementree = True
 
 try:
diff --git a/indra/lib/python/indra/util/named_query.py b/indra/lib/python/indra/util/named_query.py
index 688a52023ec..59c37a7218c 100644
--- a/indra/lib/python/indra/util/named_query.py
+++ b/indra/lib/python/indra/util/named_query.py
@@ -290,7 +290,10 @@ def _strip_wildcards_to_list(self, value):
 
         So, we need a vendor (or extention) for LIKE_STRING. Anyone
         want to write it?"""
-        utf8_value = unicode(value, "utf-8")
+        if isinstance(value, unicode):
+            utf8_value = value
+        else:
+            utf8_value = unicode(value, "utf-8")
         esc_list = []
         remove_chars = set(u"%_")
         for glyph in utf8_value:
@@ -351,11 +354,11 @@ def run(self, connection, params, expect_rows = None, use_dictcursor = True):
             cursor = connection.cursor(MySQLdb.cursors.DictCursor)
         else:
             cursor = connection.cursor()
-        
-        statement = self.sql(connection, params)
+
+        full_query, params = self._construct_sql(params)
         if DEBUG:
-            print "SQL:", statement
-        rows = cursor.execute(statement)
+            print "SQL:", self.sql(connection, params)
+        rows = cursor.execute(full_query, params)
         
         # *NOTE: the expect_rows argument is a very cheesy way to get some
         # validation on the result set.  If you want to add more expectation
@@ -364,8 +367,8 @@ def run(self, connection, params, expect_rows = None, use_dictcursor = True):
             expect_rows = 1
         if expect_rows is not None and rows != expect_rows:
             cursor.close()
-            raise ExpectationFailed("Statement expected %s rows, got %s.  Sql: %s" % (
-                expect_rows, rows, statement))
+            raise ExpectationFailed("Statement expected %s rows, got %s.  Sql: '%s' %s" % (
+                expect_rows, rows, full_query, params))
 
         # convert to dicts manually if we're not using a dictcursor
         if use_dictcursor:
@@ -391,11 +394,9 @@ def run(self, connection, params, expect_rows = None, use_dictcursor = True):
             return result_set[0]
         return result_set
 
-    def sql(self, connection, params):
-        """ Generates an SQL statement from the named query document
-        and a dictionary of parameters.
-
-        """
+    def _construct_sql(self, params):
+        """ Returns a query string and a dictionary of parameters,
+        suitable for directly passing to the execute() method."""
         self.refresh()
 
         # build the query from the options available and the params
@@ -443,10 +444,23 @@ def sql(self, connection, params):
                 new_params[self._build_integer_key(key)] = int(params[key])
         params.update(new_params)
 
+        return full_query, params
+
+    def sql(self, connection, params):
+        """ Generates an SQL statement from the named query document
+        and a dictionary of parameters.
+
+        *NOTE: Only use for debugging, because it uses the
+         non-standard MySQLdb 'literal' method.
+        """
+        if not DEBUG:
+            import warnings
+            warnings.warn("Don't use named_query.sql() when not debugging.  Used on %s" % self._location)
         # do substitution using the mysql (non-standard) 'literal'
         # function to do the escaping.
-        sql = full_query % connection.literal(params)
-        return sql
+        full_query, params = self._construct_sql(params)
+        return full_query % connection.literal(params)
+        
 
     def refresh(self):
         """ Refresh self from the file on the filesystem.
diff --git a/indra/llinventory/lltransactiontypes.h b/indra/llinventory/lltransactiontypes.h
index d70109804c4..1cb7308bd41 100644
--- a/indra/llinventory/lltransactiontypes.h
+++ b/indra/llinventory/lltransactiontypes.h
@@ -45,6 +45,7 @@
 // Money transaction failure codes
 const U8 TRANS_FAIL_SIMULATOR_TIMEOUT	= 1;
 const U8 TRANS_FAIL_DATASERVER_TIMEOUT	= 2;
+const U8 TRANS_FAIL_APPLICATION         = 3;
 
 // Codes up to 999 for error conditions
 const S32 TRANS_NULL				= 0;
-- 
GitLab