changeset 416:e7769bc81960

several changes to settables - incomplete
author catherine@bothari
date Tue, 03 Nov 2009 15:32:19 -0500
parents 3a2db0db302f
children fc3e99c9e3e5
files sqlpython/sqlpyPlus.py sqlpython/sqlpython.py
diffstat 2 files changed, 32 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Fri Oct 30 19:45:23 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Tue Nov 03 15:32:19 2009 -0500
@@ -357,15 +357,26 @@
             'resource', 'revoke', 'select', 'share', 'start', 'union', 'update', 
             'where', 'with']    
     default_file_name = 'afiedt.buf'
+    settable = sqlpython.settable + '''
+        autobind
+        bloblimit
+        colors
+        commit_on_exit
+        default_rdbms
+        maxfetch
+        maxtselctrows
+        rows_remembered
+        scan
+        serveroutput
+        sql_echo
+        timeout
+        heading
+        wildsql
+        version'''
     def __init__(self):
         sqlpython.sqlpython.__init__(self)
         self.binds = CaselessDict()
-        self.settable += '''autobind bloblimit colors commit_on_exit 
-                            default_rdbms maxfetch maxtselctrows 
-                            rows_remembered scan serveroutput 
-                            sql_echo timeout heading wildsql version'''.split()
         self.settable.remove('case_insensitive')
-        self.settable.sort()
         self.stdoutBeforeSpool = sys.stdout
         self.sql_echo = False
         self.spoolFile = None
@@ -660,7 +671,9 @@
             prompt = ''
         varname = args.lower().split()[0]
         self.substvars[varname] = self.pseudo_raw_input(prompt)
-                
+
+    #TODO: double-ampersand not working
+    #substvars not remembered b/t queries
     def ampersand_substitution(self, raw, regexpr, isglobal):
         subst = regexpr.search(raw)
         while subst:
@@ -700,9 +713,10 @@
                           help='Bind row #ROW instead of final row (zero-based)')])    
     def do_bind(self, arg, opts):
         '''
-        Inserts the results from the final row in the last completed SELECT statement
-        into bind variables with names corresponding to the column names.  When the optional 
-        `autobind` setting is on, this will be issued automatically after every query that 
+        Inserts the results from the final row in the last completed
+        SELECT statement into bind variables with names corresponding 
+        to the column names.  When the optional `autobind` setting is
+        on, this will be issued automatically after every query that 
         returns exactly one row.
         '''
         try:
@@ -918,7 +932,11 @@
                                (program, os.getcwd()))
             if not create.strip().lower().startswith('y'):
                 return
-        subprocess.call([program, 'init'])
+        try:
+            subprocess.call([program, 'init'])
+        except OSError:
+            self.perror('Call to %s failed; is it installed and in PATH?' % program)
+            return
         opts.dump = True
         self._pull(arg, opts, vc=[program, 'add'])
         subprocess.call([program, 'commit', '-m', '"%s"' % opts.message or 'committed from sqlpython'])        
@@ -1051,11 +1069,12 @@
                         break
                 self.poutput(''.join(l for (ln, l) in m.db_object.source[:index]))
                         
-            
-    def do_deps(self, arg):
+    @options([all_users_option])            
+    def do_deps(self, arg, opts):
         '''Lists all objects that are dependent upon the object.'''
         #TODO: Can this be Geraldized?
         for obj in self._matching_database_objects(arg, opts):
+            obj.db_object.triggers
 
             if object_type == 'PACKAGE BODY':
                 q = "and (type != 'PACKAGE BODY' or name != :object_name)'"
--- a/sqlpython/sqlpython.py	Fri Oct 30 19:45:23 2009 -0400
+++ b/sqlpython/sqlpython.py	Tue Nov 03 15:32:19 2009 -0500
@@ -333,6 +333,7 @@
                    'postgres': Parser(pyparsing.Literal('%(') + legal_sql_word + ')s')}
     def findBinds(self, target, givenBindVars = {}):
         result = givenBindVars
+        #TODO: A consistent bind style?  As a setting, perhaps?
         if self.rdbms in self.bindScanner:
             for finding, startat, endat in self.bindScanner[self.rdbms].scanner.scanString(target):
                 varname = finding[1]