# HG changeset patch # User catherine.devlin@gmail.com # Date 1285375080 14400 # Node ID 9dbf9965313684103d92cb1f459f93912f163e5e # Parent c8de86e7cd063cb6af2c276c09deba22824ef02b fixed body ddl for packages diff -r c8de86e7cd06 -r 9dbf99653136 sqlpython/sqlpyPlus.py --- a/sqlpython/sqlpyPlus.py Fri Sep 24 19:00:37 2010 -0400 +++ b/sqlpython/sqlpyPlus.py Fri Sep 24 20:38:00 2010 -0400 @@ -868,30 +868,32 @@ try: for (owner, object_type, name, synonym_name) in self.current_instance.objects(arg, opts): obj = self.current_instance.object_metadata(owner, object_type, name) - txt = obj.get_ddl() - if opts.get('lines'): - txt = self._with_line_numbers(txt) - if opts.dump: - path = os.path.join(owner.lower(), object_type.lower()).replace(' ', '_') - try: - os.makedirs(path) - except OSError: - pass - filename = os.path.join(path, '%s.sql' % name.lower()) - self.stdout = open(filename, 'w') - if opts.get('num') is not None: - txt = txt.splitlines() - txt = centeredSlice(txt, center=opts.num+1, width=opts.width) - txt = '\n'.join(txt) - else: - txt = 'REMARK BEGIN %(object_label)s\n%(txt)s\nREMARK END %(object_label)s\n' % { - 'object_label': self.object_label(object_type, owner, name, None), 'txt': txt} - self.poutput(txt) - if opts.dump: - self.stdout.close() - statekeeper.restore() - if vc: - subprocess.call(vc + [filename]) + txts = [(object_type, obj.get_ddl())] + if hasattr(obj, 'get_body_ddl'): + txts.append(('PACKAGE BODY', obj.get_body_ddl())) + for (object_type, txt) in txts: + if opts.get('lines'): + txt = self._with_line_numbers(txt) + if opts.dump: + path = os.path.join(owner.lower(), object_type.lower()).replace(' ', '_') + try: + os.makedirs(path) + except OSError: + pass + filename = os.path.join(path, '%s.sql' % name.lower()) + self.stdout = open(filename, 'w') + if opts.get('num') is not None: + txt = txt.splitlines() + txt = centeredSlice(txt, center=opts.num+1, width=opts.width) + txt = '\n'.join(txt) + else: + txt = 'REMARK BEGIN\n%s\nREMARK END\n/\n\n' % txt + self.poutput(txt) + if opts.dump: + self.stdout.close() + statekeeper.restore() + if vc: + subprocess.call(vc + [filename]) except: statekeeper.restore() raise