Changeset 2748

Show
Ignore:
Timestamp:
01/24/07 15:38:20 (2 years ago)
Author:
carl
Message:

merged with trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/carl2/AUTHORS

    r2713 r2748  
    1414    Nate Lowrie 
    1515    Uwe Grauer 
     16    Simen Haugen 
    1617 
    1718 
  • branches/carl2/ChangeLog

    r2684 r2748  
    22 
    33=============================================================================== 
    4 Dabo 0.7.2 (2007-01-15) (Revision 2683): 
     4Dabo 0.7.2 (2007-01-18) (Revision 2716): 
    55 
    66Additions, all minor, backported to stable only to keep compatibility with the  
     
    1313+ Fixed the stable branch to work with wxPython 2.7 and 2.8, which was a fairly 
    1414  large backport of relevant changes from the development trunk. 
     15+ Fixed a form activation problem that would happen in some cases on Windows,  
     16  particularly with the Class Designer. 
    1517+ Fixed incremental search in dGrid, which was broken by earlier unicode fixes. 
    1618+ dBizobj.onSaveNew() user hook never being called. Fixed. 
  • branches/carl2/dabo/LICENSE.TXT

    r2205 r2748  
    11Dabo: 3-tier desktop application runtime framework 
    2 Copyright (c) 2004-2006 Ed Leafe, Paul McNett, et. al. 
     2Copyright (c) 2004-2007 Ed Leafe, Paul McNett, et. al. 
    33 
    44Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 
  • branches/carl2/dabo/biz/dAutoBizobj.py

    r2412 r2748  
    169169            f.write("%s;\n" % (query)) 
    170170 
    171     f.close 
     171    f.close() 
    172172 
    173173class dAutoBizobj(dBizobj): 
  • branches/carl2/dabo/biz/dBizobj.py

    r2713 r2748  
    258258        useTransact = startTransaction or topLevel 
    259259        cursor = self._CurrentCursor 
    260         old_pk = cursor.getPK() 
     260        current_row = self.RowNumber 
    261261 
    262262        if useTransact: 
     
    288288            cursor.commitTransaction() 
    289289 
    290         if old_pk is not None: 
    291             self._moveToPK(old_pk) 
     290        self.RowNumber = current_row 
    292291 
    293292 
     
    878877    def isAnyChanged(self, _topLevel=True): 
    879878        """Returns True if any record in the current record set has been changed.""" 
    880  
     879        try: 
     880            cc = self._CurrentCursor 
     881        except: 
     882            cc = None 
     883        if cc is None: 
     884            # No cursor, no changes. 
     885            return False 
    881886        if _topLevel: 
    882887            # Only check the _CurrentCursor: 
  • branches/carl2/dabo/biz/test/test_dBizobj.py

    r2713 r2748  
    297297        bizMain.new() 
    298298        self.assertEqual(bizMain.RowCount, 4) 
     299        self.assertEqual(bizMain.RowNumber, 3) 
    299300        bizMain.saveAll() 
    300301        self.assertEqual(bizMain.RowCount, 4) 
     302        self.assertEqual(bizMain.RowNumber, 3) 
    301303        bizMain.requery()        
    302304        self.assertEqual(bizMain.RowCount, 4) 
     305        self.assertEqual(bizMain.RowNumber, 3) 
    303306 
    304307 
  • branches/carl2/dabo/db/dBackend.py

    r2712 r2748  
    209209            self._autoCommit = val 
    210210        else: 
    211             # Without an autocommit method, assume 
    212             # no autocommit. 
     211            # Without an autocommit method, assume no autocommit. 
    213212            self._autoCommit = False 
     213            if val: 
     214                raise ValueError, "Can't set AutoCommit to True for this backend." 
    214215 
    215216 
  • branches/carl2/dabo/db/dbFirebird.py

    r2713 r2748  
    9595            whereClause = '' 
    9696        else: 
    97             whereClause = "where rdb$relation_name not like 'RDB$%' " 
     97            whereClause = "where rdb$relation_name not starting with 'RDB$' " 
    9898             
    9999        tempCursor = self._connection.cursor() 
  • branches/carl2/dabo/db/dbPostgreSQL.py

    r2672 r2748  
    1313        self.dbModuleName = "psycopg" 
    1414        self.useTransactions = True  # this does not appear to be required 
     15        self.conn_user = '' 
    1516 
    1617 
     
    1819        import psycopg2 as dbapi 
    1920        #from pyPgSQL import PgSQL as dbapi 
    20          
     21        self.conn_user = connectInfo.User 
    2122        #- jfcs 11/01/04 port needs to be a string 
    2223        port = str(connectInfo.Port) 
     
    5354        tempCursor = self._connection.cursor() 
    5455        # jfcs 11/01/04 assumed public schema 
    55         tempCursor.execute("select tablename from pg_tables where schemaname = 'public'") 
     56        #tempCursor.execute("select tablename from pg_tables where schemaname = 'public'") 
     57        # jfcs 01/22/07 added below to support schema  
     58        # thanks to Phillip J. Allen who provided a Select state that filtered for the user name 
     59        if includeSystemTables: 
     60            sqltablestr = (("SELECT schemaname || '.' || tablename AS tablename FROM pg_tables WHERE has_table_privilege('%s', schemaname || '.' || tablename, 'SELECT')") % self.conn_user) 
     61     
     62        else: 
     63            sqltablestr = (("SELECT schemaname || '.' || tablename AS tablename FROM pg_tables WHERE (schemaname not like 'pg_%s' and schemaname not like 'information%s') and has_table_privilege('%s', schemaname || '.' || tablename, 'SELECT')") % ('%','%',self.conn_user)) 
     64                         
     65        tempCursor.execute(sqltablestr) 
    5666        rs = tempCursor.fetchall() 
     67         
     68         
    5769        tables = [] 
    5870        for record in rs: 
     
    7688        # make sure you uncomment the other code out 
    7789         
     90        # jfcs 01/22/07 actually I'm not sure Dabo is still able to support 7.1 - 7.4 
     91        # should you attempt to Dabo with 7.4 or below please let us know. 
     92         
    7893        #tempCursor.execute("select c.column_name as fielname, c.data_type as fieldtyp, \ 
    7994        #i.indisprimary AS is_pkey \ 
     
    85100        #rs=tempCursor.fetchall() 
    86101         
    87         # jfcs 11/01/04 Below sucks but works with 7.3.x and 7.4.x (don't know anything 
    88         # about 8.0.x)  
     102         
    89103        # Ok get the 'field name', 'field type' 
    90         tempCursor.execute("""select c.oid,a.attname, t.typname  
    91                 from pg_class c inner join pg_attribute a  
    92                 on a.attrelid = c.oid inner join pg_type t on a.atttypid = t.oid  
    93                 where c.relname = '%s' and a.attnum > 0 """ % tableName) 
     104        #tempCursor.execute("""select c.oid,a.attname, t.typname  
     105                #from pg_class c inner join pg_attribute a  
     106                #on a.attrelid = c.oid inner join pg_type t on a.atttypid = t.oid  
     107                #where c.relname = '%s' and a.attnum > 0 """ % tableName) 
     108        # JFCS 01/22/07 Added support for schema  
     109        tempCursor.execute("""select c.oid,a.attname, t.typname, b.schemaname from pg_class c  
     110inner join pg_attribute a on a.attrelid = c.oid  
     111inner join pg_type t on a.atttypid = t.oid  
     112inner join pg_tables b on b.tablename=c.relname 
     113where (b.schemaname || '.'|| c.relname)  = '%s' and a.attnum > 0 """ % tableName) 
    94114        rs = tempCursor.fetchall() 
    95115        myoid=rs[0][0] 
     
    125145            elif "numeric" in fldType: 
    126146                fldType = "N" 
     147            elif "double" in fldType: 
     148                fldType = "F" 
     149            elif "real" in fldType: 
     150                fldType = "F" 
     151            elif "float" in fldType: 
     152                fldType = "F" 
    127153            elif "datetime" in fldType: 
    128154                fldType = "T" 
  • branches/carl2/dabo/db/test/test_dCursorMixin.py

    r2713 r2748  
    2525 
    2626class Test_dCursorMixin(object): 
    27     def setUp(self): 
     27    def setUp(self, _doRequery=True): 
    2828        cur = self.cur 
    2929        self.createSchema() 
     
    3131        cur.KeyField = "pk" 
    3232        cur.Table = self.temp_table_name 
    33         cur.requery() 
     33        if _doRequery: 
     34            cur.requery() 
    3435 
    3536    def tearDown(self): 
     
    4041        cur = self.cur 
    4142 
     43    def getAdditionalWhere(self): 
     44        return "" 
    4245 
    4346    ## - Begin property unit tests - 
     
    4548        cur = self.cur 
    4649        self.assertEqual(cur.AutoCommit, False) 
    47         cur.AutoCommit = True 
    48         self.assertEqual(cur.AutoCommit, True) 
     50        try: 
     51            cur.AutoCommit = True 
     52            self.assertEqual(cur.AutoCommit, True) 
     53        except ValueError: 
     54            # Okay; this db didn't allow the setting of AutoCommit. 
     55            self.assertEqual(cur.AutoCommit, False) 
    4956 
    5057    def test_AutoSQL(self): 
     
    7481        self.assertTrue(ds[0] == ("pk", "I", True, self.temp_table_name, "pk", None) 
    7582                or ds[0] == ("pk", "G", True, self.temp_table_name, "pk", None)) 
    76         self.assertEqual(ds[1], ("cField", "C", False, self.temp_table_name, "cField", None)) 
    77         self.assertTrue(ds[2] == ("iField", "I", False, self.temp_table_name, "iField", None) 
    78                 or ds[2] == ("iField", "G", False, self.temp_table_name, "iField", None)) 
    79         self.assertEqual(ds[3], ("nField", "N", False, self.temp_table_name, "nField", None)) 
     83        self.assertEqual(ds[1], ("cfield", "C", False, self.temp_table_name, "cfield", None)) 
     84        self.assertTrue(ds[2] == ("ifield", "I", False, self.temp_table_name, "ifield", None) 
     85                or ds[2] == ("ifield", "G", False, self.temp_table_name, "ifield", None)) 
     86        self.assertEqual(ds[3], ("nfield", "N", False, self.temp_table_name, "nfield", None)) 
    8087 
    8188    def test_Encoding(self): 
     
    9198        cur = self.cur 
    9299        self.assertEqual(cur.FieldDescription[0][0], "pk") 
    93         self.assertEqual(cur.FieldDescription[1][0], "cField") 
    94         self.assertEqual(cur.FieldDescription[2][0], "iField") 
    95         self.assertEqual(cur.FieldDescription[3][0], "nField") 
     100        self.assertEqual(cur.FieldDescription[1][0], "cfield") 
     101        self.assertEqual(cur.FieldDescription[2][0], "ifield") 
     102        self.assertEqual(cur.FieldDescription[3][0], "nfield") 
    96103 
    97104    def test_IsAdding(self): 
     
    107114    def test_LastSQL(self): 
    108115        cur = self.cur 
    109         self.assertEqual(cur.LastSQL, cur.UserSQL) 
     116        current_sql = cur.UserSQL 
     117        cur.UserSQL = "select blah from temp" 
     118        self.assertEqual(cur.UserSQL, "select blah from temp") 
     119        self.assertEqual(cur.LastSQL, current_sql) 
    110120 
    111121    def test_KeyField(self): 
     
    115125    def test_Record(self): 
    116126        cur = self.cur 
    117         self.assertEqual(cur.Record.cField, "Paul Keith McNett") 
    118         cur.Record.cField = "Denise McNett" 
    119         self.assertEqual(cur.Record.cField, "Denise McNett") 
    120         self.assertEqual(cur._mementos[cur.Record.pk]["cField"], "Paul Keith McNett") 
    121         cur.Record.cField = "Alison Anton" 
    122         self.assertEqual(cur.Record.cField, "Alison Anton") 
    123         self.assertEqual(cur._mementos[cur.Record.pk]["cField"], "Paul Keith McNett") 
    124         cur.setFieldVal("iField", 80) 
    125         self.assertEqual(cur.Record.iField, 80) 
    126         self.assertTrue(isinstance(cur.Record.iField, (int, long))) 
    127         self.assertEqual(cur._mementos[self.cur.Record.pk]["iField"], 23) 
     127        self.assertEqual(cur.Record.cfield.rstrip(), "Paul Keith McNett") 
     128        cur.Record.cfield = "Denise McNett" 
     129        self.assertEqual(cur.Record.cfield, "Denise McNett") 
     130        self.assertEqual(cur._mementos[cur.Record.pk]["cfield"].rstrip(), "Paul Keith McNett") 
     131        cur.Record.cfield = "Alison Anton" 
     132        self.assertEqual(cur.Record.cfield, "Alison Anton") 
     133        self.assertEqual(cur._mementos[cur.Record.pk]["cfield"].rstrip(), "Paul Keith McNett") 
     134        cur.setFieldVal("ifield", 80) 
     135        self.assertEqual(cur.Record.ifield, 80) 
     136        self.assertTrue(isinstance(cur.Record.ifield, (int, long))) 
     137        self.assertEqual(cur._mementos[self.cur.Record.pk]["ifield"], 23) 
    128138 
    129139        # Querying or setting a field that doesn't exist should raise 
     
    162172    def test_UserSQL(self): 
    163173        cur = self.cur 
    164         testSQL = "select * from %s where nField = 23.23" % self.temp_table_name 
     174        testSQL = "select * from %s where nfield = 23.23" % self.temp_table_name 
     175        addWhere = self.getAdditionalWhere() 
     176        if addWhere:     
     177            testSQL += " AND %s" % addWhere 
    165178        cur.UserSQL = testSQL 
    166179        cur.requery() 
     
    169182        self.assertEqual(cur.RowCount, 1) 
    170183        self.assertEqual(cur.RowNumber, 0) 
    171         self.assertEqual(cur.Record.cField, "Paul Keith McNett") 
     184        self.assertEqual(cur.Record.cfield.rstrip(), "Paul Keith McNett") 
    172185 
    173186    ## - End property unit tests - 
     
    180193        self.assertEqual(cur._newRecords, {}) 
    181194     
    182         priorVal = cur.Record.cField 
     195        priorVal = cur.Record.cfield 
    183196        # Make a change that is the same as the prior value: 
    184         cur.Record.cField = priorVal 
    185         self.assertEqual(priorVal, cur.Record.cField) 
     197        cur.Record.cfield = priorVal 
     198        self.assertEqual(priorVal, cur.Record.cfield) 
    186199        self.assertEqual(cur._mementos, {}) 
    187200        self.assertEqual(cur._newRecords, {}) 
    188201 
    189202        # Make a change that is different: 
    190         cur.Record.cField = "New test value" 
    191         self.assertEqual(cur._mementos, {cur.Record.pk: {"cField": priorVal}}) 
     203        cur.Record.cfield = "New test value" 
     204        self.assertEqual(cur._mementos, {cur.Record.pk: {"cfield": priorVal}}) 
    192205        self.assertEqual(cur.isChanged(), True) 
    193206        self.assertEqual(cur.isChanged(allRows=False), True) 
    194207 
    195208        # Change it back: 
    196         cur.Record.cField = priorVal 
     209        cur.Record.cfield = priorVal 
    197210        self.assertEqual(cur._mementos, {}) 
    198211        self.assertEqual(cur.isChanged(), False) 
     
    200213 
    201214        # Make a change that is different and cancel: 
    202         cur.Record.cField = "New test value" 
     215        cur.Record.cfield = "New test value" 
    203216        cur.cancel() 
    204217        self.assertEqual(cur._mementos, {}) 
     
    219232        self.assertEqual(cur.isChanged(allRows=False), True) 
    220233        self.assertEqual(cur.Record.pk, "-1-dabotmp") 
    221         self.assertEqual(cur.Record.cField, "") 
    222         self.assertEqual(cur.Record.iField, 0) 
    223         self.assertEqual(cur.Record.nField, 0) 
     234        self.assertEqual(cur.Record.cfield, "") 
     235        self.assertEqual(cur.Record.ifield, 0) 
     236        self.assertEqual(cur.Record.nfield, 0) 
    224237        cur.save() 
    225238        cur.requery() 
     
    232245 
    233246        # The new fields should be NULL, since we didn't explicitly set them: 
    234         self.assertEqual(cur.Record.cField, None) 
    235         self.assertEqual(cur.Record.iField, None) 
    236         self.assertEqual(cur.Record.nField, None) 
     247        self.assertEqual(cur.Record.cfield, None) 
     248        self.assertEqual(cur.Record.ifield, None) 
     249        self.assertEqual(cur.Record.nfield, None) 
    237250 
    238251 
     
    248261        tableName = self.temp_table_name 
    249262        cur.executescript(""" 
    250 create table %s (pk INTEGER PRIMARY KEY AUTOINCREMENT, cField CHAR, iField INT, nField DECIMAL (8,2)); 
    251 insert into %s (cField, iField, nField) values ("Paul Keith McNett", 23, 23.23); 
    252 insert into %s (cField, iField, nField) values ("Edward Leafe", 42, 42.42); 
    253 insert into %s (cField, iField, nField) values ("Carl Karsten", 10223, 23032.76); 
     263create table %s (pk INTEGER PRIMARY KEY AUTOINCREMENT, cfield CHAR, ifield INT, nfield DECIMAL (8,2)); 
     264insert into %s (cfield, ifield, nfield) values ("Paul Keith McNett", 23, 23.23); 
     265insert into %s (cfield, ifield, nfield) values ("Edward Leafe", 42, 42.42); 
     266insert into %s (cfield, ifield, nfield) values ("Carl Karsten", 10223, 23032.76); 
    254267""" % (tableName, tableName, tableName, tableName, )) 
    255268 
     
    271284        cur = self.cur 
    272285        cur.execute(""" 
    273 create table %s (pk INTEGER PRIMARY KEY AUTO_INCREMENT, cField CHAR (32), iField INT, nField DECIMAL (8,2)) 
     286create table %s (pk INTEGER PRIMARY KEY AUTO_INCREMENT, cfield CHAR (32), ifield INT, nfield DECIMAL (8,2)) 
    274287""" % self.temp_table_name) 
    275288        cur.execute("""      
    276 insert into %s (cField, iField, nField) values ("Paul Keith McNett", 23, 23.23) 
     289insert into %s (cfield, ifield, nfield) values ("Paul Keith McNett", 23, 23.23) 
    277290""" % self.temp_table_name) 
    278291        cur.execute("""      
    279 insert into %s (cField, iField, nField) values ("Edward Leafe", 42, 42.42) 
     292insert into %s (cfield, ifield, nfield) values ("Edward Leafe", 42, 42.42) 
    280293""" % self.temp_table_name) 
    281294        cur.execute("""      
    282 insert into %s (cField, iField, nField) values ("Carl Karsten", 10223, 23032.76) 
     295insert into %s (cfield, ifield, nfield) values ("Carl Karsten", 10223, 23032.76) 
    283296""" % self.temp_table_name) 
    284297 
     
    293306                password="Y57W8EN6CB06KBCCDCX01D6B", Database="dabo_unittest", 
    294307                Host="dabodev.com") 
    295         self.cur = con.getDaboCursor() 
     308        cur = self.cur = con.getDaboCursor() 
    296309        self.temp_table_name = "dabo_unittest_tbl" 
    297310        self.jobid = self.get_jobid() 
    298         super(Test_dCursorMixin_firebird, self).setUp() 
     311        super(Test_dCursorMixin_firebird, self).setUp(_doRequery=False) 
     312        cur.UserSQL = "select * from %s where jobid = %s" % (self.temp_table_name, self.jobid) 
     313        cur.requery() 
    299314 
    300315    def get_jobid(self): 
     
    310325        super(Test_dCursorMixin_firebird, self).tearDown() 
    311326 
     327    def getAdditionalWhere(self): 
     328        return "jobid = %f" % self.jobid 
     329 
    312330    def createSchema(self): 
    313331        cur = self.cur 
     
    316334        cur.execute("commit") 
    317335        cur.execute("""      
    318 insert into %s (jobid, cField, iField, nField) values (%f, 'Paul Keith McNett', 23, 23.23) 
     336insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Paul Keith McNett', 23, 23.23) 
    319337""" % (tableName, self.jobid)) 
    320338        cur.execute("""      
    321 insert into %s (jobid, cField, iField, nField) values (%f, 'Edward Leafe', 42, 42.42) 
     339insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Edward Leafe', 42, 42.42) 
    322340""" % (tableName, self.jobid)) 
    323341        cur.execute("""      
    324 insert into %s (jobid, cField, iField, nField) values (%f, 'Carl Karsten', 10223, 23032.76) 
     342insert into %s (jobid, cfield, ifield, nfield) values (%f, 'Carl Karsten', 10223, 23032.76) 
    325343""" % (tableName, self.jobid)) 
    326344        cur.execute("commit") 
     
    328346    def test_AutoSQL(self): 
    329347        cur = self.cur 
    330         self.assertEqual(cur.AutoSQL, "select first 1000 skip 0 *\n  from %s
     348        self.assertEqual(cur.AutoSQL, "SELECT \n first 1000\n*\n  from %s\n\n\n
    331349                % self.temp_table_name) 
     350 
    332351 
    333352if __name__ == "__main__": 
  • branches/carl2/dabo/lib/DesignerXmlConverter.py

    r2618 r2748  
    145145        for prop, propDef in propDefs.items(): 
    146146            val = propDef["defaultValue"] 
     147            if not val: 
     148                continue 
    147149            if propDef["defaultType"] == "string": 
    148150                val = "\"" + val + "\"" 
  • branches/carl2/dabo/lib/EasyDialogBuilder.py

    r2713 r2748  
    3636                page["imgKey"]=str(pageFrame.PageCount) 
    3737                pageFrame.addImage(page["image"], imgKey=page["imgKey"]) 
     38            elif not page.get("caption"): 
     39                caption = "Page%i" % (pageFrame.PageCount,)  
    3840             
    3941            pageFrame.appendPage(pgCls=page.get("page"), caption=page.get("caption"), imgKey=page.get("imgKey")) 
     
    4143        return pageFrame 
    4244 
    43     def makeControlBox(self, parent, caption, controlFields, border=5, spacing=5): 
    44         """makeControlBox(parent, controlFields, border=5, spacing=5) -> dabo.ui.dBorderSizer 
     45    def makeControlBox(self, parent, caption, controlFields, border=5, spacing=5, grid=True): 
     46        """makeControlBox(parent, controlFields, border=5, spacing=5, grid=True) -> dabo.ui.dBorderSizer 
    4547         
    4648        parent -> dabo object that is the parent of the controls, normally a panel or form 
     49        grid -> Boolean.  When true all objects are put into a grid sizer for even controlfield alignment. 
     50            When false, all objects are put into boxSizers so the control fields line up with the end 
     51            of their labels. 
    4752        controlFields -> Tuple of tuples in form of: 
    4853            ((control, RegID, label Title, Properties),.....) 
     
    6368        box.DefaultBorderAll = True 
    6469         
    65         for obj in controlFields: 
    66             if len(obj)==4 and isinstance(obj[3], types.DictionaryType): 
    67                 Properties = obj[3] 
    68             else: 
    69                 Properties = {} 
    70             bs = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 
    71              
    72             if obj[0] is dabo.ui.dEditBox: 
    73                 box.append(bs, "expand", 1) 
    74             else: 
    75                 box.append(bs, "expand") 
     70        box.append1x(self.makeControlSizer(parent, controlFields, grid=grid)) 
    7671         
    7772        return box 
    7873     
    79     def makeControlSizer(self, parent, controlFields, border=5, spacing=5): 
    80         """makeControlSizer(parent, controlFields, border=5, spacing=5) -> dabo.ui.dSizer 
     74    def makeControlSizer(self, parent, controlFields, border=5, spacing=5, grid=True): 
     75        """makeControlSizer(parent, controlFields, border=5, spacing=5, grid=True) -> dabo.ui.dSizer 
    8176         
    8277        parent -> dabo object that is the parent of the controls, normally a panel or form 
     78        grid -> Boolean.  When true all objects are put into a grid sizer for even controlfield alignment. 
     79            When false, all objects are put into boxSizers so the control fields line up with the end 
     80            of their labels. 
    8381        controlFields -> Tuple of tuples in form of: 
    8482            ((control, RegID, label Title, Properties),.....) 
     
    9290            "format" = string will cause the control to only allow the user to select that file type 
    9391        """ 
    94         vs = dabo.ui.dSizer("vertical") 
    95         vs.DefaultSpacing = spacing 
    96         vs.DefaultBorder = border 
    97         vs.DefaultBorderAll = True 
     92        if grid: 
     93            Sizer = dabo.ui.dGridSizer(MaxCols=3) 
     94            Sizer.setColExpand(True, 1) 
     95        else: 
     96            Sizer = dabo.ui.dSizer("vertical") 
     97         
     98        Sizer.DefaultSpacing = spacing 
     99        Sizer.DefaultBorder = border 
     100        Sizer.DefaultBorderAll = True 
    98101         
    99102        for obj in controlFields: 
     
    102105            else: 
    103106                Properties = {} 
    104             bs = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 
    105              
    106             if obj[0] is dabo.ui.dEditBox: 
    107                 vs.append(bs, "expand", 1) 
    108             else: 
    109                 vs.append(bs, "expand") 
    110          
    111         return vs 
    112      
    113     def makeControlField(self, parent, control, regId, labelTitle, Properties): 
    114         """makeControlField(parent, control, regId, labelTitle, Properties) -> dabo.ui.dSizer 
     107             
     108            controls = self.makeControlField(parent, obj[0], obj[1], obj[2], Properties) 
     109             
     110            if grid: 
     111                lbl = Sizer.append(controls[0], halign="right") 
     112                if len(controls) > 2: 
     113                    Sizer.append(controls[1], "expand") 
     114                    Sizer.append(controls[2]) 
     115                else: 
     116                    szItem = Sizer.append(controls[1], "expand", colSpan=2) 
     117                 
     118                if obj[0] is dabo.ui.dEditBox: 
     119                    Sizer.setRowExpand(True, Sizer.getGridPos(szItem)[0]) 
     120                    Sizer.setItemProp(lbl, "valign", "top") 
     121            else: 
     122                bs = dabo.ui.dSizer("h") 
     123                bs.append(controls[0], halign="right") 
     124                bs.append(controls[1], "expand",1) 
     125                 
     126                if len(controls) > 2: 
     127                    bs.append(controls[2]) 
     128                 
     129                if obj[0] is dabo.ui.dEditBox: 
     130                    Sizer.append(bs, "expand", 1) 
     131                else: 
     132                    Sizer.append(bs, "expand") 
     133         
     134        return Sizer 
     135     
     136    def makeControlField(self, parent, control, regId, labelTitle, Properties, Sizer=None): 
     137        """makeControlField(parent, control, regId, labelTitle, Properties) -> List of Dabo Controls 
    115138         
    116139        parent -> dabo object that is parent, normally a panel or form 
     
    119142        labelTitle -> string that is the title of the label next to the control 
    120143        Properties -> dictionary of any properties that are supposed to go with the control 
    121         """ 
    122         bs = dabo.ui.dSizer("horizontal") 
     144        Sizer -> Optional Sizer object.  Used so we can insert objects directly into Grid Sizers 
     145        """ 
     146         
     147        if not Sizer: 
     148            Sizer = dabo.ui.dSizer("horizontal") 
     149         
     150        controlList = [] 
    123151         
    124152        if control == "File": 
     
    135163                del Properties["directory"] 
    136164             
    137              
    138             bs.append(dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption="%s:" % (labelTitle,)), "normal") 
     165            labelTitle += ":" 
     166             
    139167            target = dabo.ui.dTextBox(parent, RegID=regId, ReadOnly=True, properties=Properties) 
    140             bs.append(target, "normal", 1) 
    141             bs.appendSpacer(5) 
    142             bs.append(fileButton(parent, format, "%s_button" % (regId,), directory, target), "normal") 
     168            controlList.append(target) 
     169            controlList.append(fileButton(parent, format, "%s_button" % (regId,), directory, target)) 
    143170        else: 
    144171            if issubclass(control, (dabo.ui.dCheckBox, dabo.ui.dButton)): 
     
    148175                controlCaption = "" 
    149176                labelTitle += ":" 
    150             bs.append(dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption=labelTitle), "normal") 
    151              
    152             if control is dabo.ui.dEditBox: 
    153                 layout = "expand" 
    154             else: 
    155                 layout = "normal" 
    156              
    157             bs.append(control(parent, RegID=regId, Caption=controlCaption, properties=Properties), layout, 1) 
    158          
    159         return bs 
     177             
     178            controlList.append(control(parent, RegID=regId, Caption=controlCaption, properties=Properties)) 
     179         
     180        controlList.insert(0, dabo.ui.dLabel(parent, RegID="%s_label" % (regId,), Caption=labelTitle)) 
     181        return controlList 
    160182     
    161183    def makeButtonBar(self, buttonData, orientation="horizontal"): 
  • branches/carl2/dabo/lib/datanav/__init__.py

    r2412 r2748  
    1 ## Note: as of today (1/22/2005), the dDataNav subframework is only 
    2 ## compatible with wxPython, and still calls some wx functions directly, 
    3 ## mostly DC related. 
    4  
     1import warnings 
     2from dabo.dLocalize import _ 
    53from Form import Form 
    64from Grid import Grid 
     
    108from Bizobj import Bizobj 
    119 
    12 #Form = Form 
    13 #Grid = Grid 
    14 #Page, SelectPage, EditPage, BrowsePage = Page, SelectPage, EditPage, BrowsePage 
     10warnings.warn(_("This version of the datanav framework is deprecated; please " 
     11        "run the current AppWizard to regenerate your application using the datanav2 " 
     12        "framework."), DeprecationWarning, 1) 
  • branches/carl2/dabo/ui/uiwx/dDialog.py

    r2524 r2748  
    3535        # Hook method, so that we add the buttons last 
    3636        self._addControls() 
     37 
     38        # Needed starting with wx 2.7, for the first control to have the focus: 
     39        self.setFocus() 
    3740 
    3841 
  • branches/carl2/dabo/ui/uiwx/dEditor.py

    r2619 r2748  
    12851285        self.SetSelection(-1, -1) 
    12861286        self.EnsureCaretVisible() 
     1287     
     1288     
     1289    def ensureLineVisible(self, line): 
     1290        self.EnsureVisible(line) 
     1291        self.LineNumber = line 
     1292        self.EnsureCaretVisible() 
    12871293 
    12881294 
  • branches/carl2/dabo/ui/uiwx/dFormMain.py

    r2482 r2748  
    1313        fm.dFormMixin.__init__(self, preClass, parent, properties, *args, **kwargs) 
    1414     
    15       self.Size = (640, 480) 
    16       self.Position = (-1, -1) 
     15#     self.Size = (640, 480) 
     16#     self.Position = (-1, -1) 
    1717 
    1818        if wx.Platform != '__WXMAC__': 
    1919            self.CreateStatusBar() 
    2020 
    21          
    22     def _afterInit(self): 
    23         super(dFormMainBase, self)._afterInit() 
    24          
    25         # This is to accomodate the Dabo icon, which has a white background. 
    26         # We should set the white as transparent and set a mask, though. 
    27         self.BackColor = "White" 
    28          
    29         # Set up the Dabo icon 
    30         self.bitmap = self.drawBitmap("dabo_lettering_250x100", x=10, y=0) 
    31         plat = self.Application.Platform.lower() 
    32         off = 150 
    33         if plat == "win": 
    34             off = 180 
    35         elif plat == "gtk": 
    36             off = 160 
    37         self.bitmap.DynamicYpos = lambda: self.Height - off 
    38         self.autoClearDrawings = True 
    39         self.bindEvent(dEvents.Resize, self.__onResize) 
    40      
    41      
    42     def __onResize(self, evt): 
    43         self.update()        
    44  
    45      
    4621    def _beforeClose(self, evt=None): 
    4722        forms2close = [frm for frm in self.Application.uiForms 
  • branches/carl2/dabo/ui/uiwx/dFormMixin.py

    r2713 r2748  
    1818 
    1919        # Windows sends two Activate events, and one of them is too early. 
    20         # Skip the first one 
    21         self._skipActivate = (self.Application.Platform == "Win") 
     20        # Skip the first one. Update: apparently on wx27 and above the  
     21        # double-activation is no longer an issue. 
     22        self._skipActivate = (wx.VERSION < (2,7) and self.Application.Platform == "Win") 
    2223 
    2324        # Extract the connection name, if any 
     
    146147                if not restoredSP: 
    147148                    if self.SaveRestorePosition: 
    148                         self.restoreSizeAndPosition(
     149                        dabo.ui.callAfter(self.restoreSizeAndPosition
    149150                 
    150151                self.raiseEvent(dEvents.Activate, evt) 
  • branches/carl2/dabo/ui/uiwx/dGrid.py

    r2713 r2748  
    452452        self.listRendererClass = wx.grid.GridCellStringRenderer 
    453453        self.stringEditorClass = wx.grid.GridCellTextEditor 
     454        self.wrapStringEditorClass = wx.grid.GridCellAutoWrapStringEditor 
    454455        self.boolEditorClass = wx.grid.GridCellBoolEditor 
    455456        self.intEditorClass = wx.grid.GridCellNumberEditor 
     
    12971298            if val: 
    12981299                self.defaultRenderers["str"] = self.defaultRenderers["string"] = self.wrapStringRendererClass 
     1300                self.defaultEditors["str"] = self.defaultEditors["string"] = self.wrapStringEditorClass 
    12991301            else: 
    13001302                self.defaultRenderers["str"] = self.defaultRenderers["string"] = self.stringRendererClass 
     1303                self.defaultEditors["str"] = self.defaultEditors["string"] = self.stringEditorClass 
    13011304            self._refreshGrid() 
    13021305        else: 
     
    42864289        self.addColumn(col) 
    42874290 
    4288       col.CustomRenderers[1] = col.stringRendererClass 
    4289       col.CustomEditors[1] = col.stringEditorClass 
     4291#         col.CustomRenderers[1] = col.stringRendererClass 
     4292#         col.CustomEditors[1] = col.stringEditorClass 
    42904293        col.HeaderFontBold = False 
    42914294 
    42924295        col = dColumn(self, Name="Person", Order=20, DataField="name", 
    42934296                DataType="string", Width=200, Caption="Celebrity Name", 
    4294                 Sortable=True, Searchable=True, Editable=True, Expand=True) 
     4297                Sortable=True, Searchable=True, Editable=True, Expand=False) 
    42954298        self.addColumn(col) 
    42964299         
     
    43064309        col = dColumn(self, Name="Color", Order=40, DataField="color", 
    43074310                DataType="string", Width=40, Caption="Favorite Color", 
    4308                 Sortable=True, Searchable=True, Editable=True, Expand=True) 
     4311                Sortable=True, Searchable=True, Editable=True, Expand=False) 
    43094312        self.addColumn(col) 
    43104313 
  • branches/carl2/dabo/ui/uiwx/dMenu.py

    r2686 r2748  
    238238 
    239239        If release is True (the default), the item is deleted as well. If release  
    240         is False, a reference to the object will be returned, and the caller  
     240        is False, a reference to the object will be returned, and the caller  
    241241        is responsible for deleting it. 
    242242        """ 
     
    245245        if self._daboChildren.has_key(id_): 
    246246            del self._daboChildren[id_] 
    247         self.RemoveItem(item) 
     247 
     248        if wx.VERSION >= (2,7): 
     249            # Needed to keep dPemMixin mixed-in in wxPython 2.8 
     250            val = wx.Menu.RemoveItem(self, item) 
     251            item.this.own(val.this.own()) 
     252            val.this.disown() 
     253        else: 
     254            self.RemoveItem(item) 
     255 
    248256        if release: 
    249             if wx.VERSION[0] == 2 and wx.VERSION[1] >= 7: 
    250                 # segfault when destroying menu items for wx2.7. I've reported it and 
    251                 # it will probably be fixed soon. For now, don't destroy it but return 
    252                 # None to the caller. 
    253                 item = None 
    254             else: 
    255                 item.Destroy() 
     257            item.Destroy() 
     258            item = None 
    256259        return item 
    257260 
  • branches/carl2/dabo/ui/uiwx/dPageFrameMixin.py

    r2583 r2748  
    335335    def _getSelectedPage(self): 
    336336        try: 
    337             ret = self.GetPage(self.GetSelection()) 
     337            sel = self.GetSelection() 
     338            if sel < 0: 
     339  &n