Contact: fumanchu@aminus.org

Log in as guest/dejavu to create tickets

I think I've seen this ORM somewhere before...

Changeset 192

Show
Ignore:
Timestamp:
03/13/06 11:27:08
Author:
fumanchu
Message:

Bugfixes and new storeado.rename_property method.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/arenas.py

    r191 r192  
    319319                for id in keys: 
    320320                    unit = cache.get(id) 
    321                     if unit and (expr is None) or expr.evaluate(unit): 
     321                    if unit and ((expr is None) or expr.evaluate(unit)): 
    322322                        # Do NOT call on_recall here. That should be called 
    323323                        # only at the Sandbox-SM boundary. 
  • trunk/storage/db.py

    r191 r192  
    14741474     
    14751475    def has_index(self, cls, name): 
    1476         return name in [i.name for i in self.get_indices(cls.__name__)] 
     1476        tablename = self.table_name(cls.__name__, quoted=False) 
     1477        indices = [i.colname for i in self.get_indices(tablename)] 
     1478        return (name in indices) 
    14771479     
    14781480    def drop_index(self, cls, name): 
  • trunk/storage/storeado.py

    r191 r192  
    137137                    return datetime.datetime(int(value[0:4]), int(value[4:6]), 
    138138                                             int(value[6:8])) 
    139                 except Exception, x
     139                except Exception
    140140                    raise ValueError("'%s' %s" % (value, type(value))) 
    141141            else: 
     
    153153                    return datetime.date(int(value[0:4]), int(value[4:6]), 
    154154                                         int(value[6:8])) 
    155                 except Exception, x
     155                except Exception
    156156                    raise ValueError("'%s' %s" % (value, type(value))) 
    157157            else: 
     
    436436        return "ADO Version: %s" % adoconn.Version 
    437437     
     438    #                               Schemas                               # 
     439     
    438440    def has_storage(self, cls): 
    439441        names = [t.name for t in self.get_tables()] 
    440442        return self.table_name(cls.__name__, quoted=False) in names 
     443     
     444    def rename_storage(self, oldname, newname): 
     445        oldname = self.table_name(oldname, quoted=False) 
     446        newname = self.table_name(newname, quoted=False) 
     447        self.arena.log("rename table %s to %s" % (oldname, newname), 
     448                       dejavu.LOGSQL) 
     449         
     450        conn = self.connection() 
     451        try: 
     452            cat = win32com.client.Dispatch(r'ADOX.Catalog') 
     453            cat.ActiveConnection = conn 
     454            cat.Tables(oldname).Name = newname 
     455        except pywintypes.com_error: 
     456            conn = None 
     457            cat = None 
     458            raise 
    441459     
    442460    def rename_property(self, cls, oldname, newname): 
     
    445463        oldname = self.column_name(clsname, oldname, quoted=False) 
    446464        newname = self.column_name(clsname, newname, quoted=False) 
     465        self.arena.log("rename %s column %s to %s" % 
     466                       (tblname, oldname, newname), 
     467                       dejavu.LOGSQL) 
    447468          
    448469        conn = self.connection() 
     
    451472            cat.ActiveConnection = conn 
    452473            cat.Tables(tblname).Columns(oldname).Name = newname 
    453         except pywintypes.com_error, x
     474        except pywintypes.com_error
    454475            conn = None 
    455476            cat = None 
     
    462483        colname = self.column_name(clsname, name, quoted=False) 
    463484         
    464         for i in self.get_indices(): 
    465             if i.tablename == tablename and i.colname == colname: 
     485        for i in self.get_indices(tablename): 
     486            if i.colname == colname: 
    466487                # The INDEX_NAME may include a trailing " ASC" or other data 
    467488                self.execute('DROP INDEX [%s] ON %s;' % (i.name, qtablename)) 
     
    938959 
    939960 
    940  
    941961def gen_py(): 
    942962    # Auto generate .py support for ADO 2.7+ 
  • trunk/units.py

    r191 r192  
    386386        # but not back up to superclasses. 
    387387        if hasattr(cls, "properties"): 
    388             props = cls.properties[:] 
     388            props = list(cls.properties) 
    389389        else: 
    390390            props = []