Changeset 2856

Show
Ignore:
Timestamp:
02/26/07 09:38:55 (1 year ago)
Author:
uwe_grauer
Message:

merged changes from trunk

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/uwe/dabo/biz/dBizobj.py

    r2836 r2856  
    3434        self._conn = conn 
    3535 
    36         super(dBizobj, self).__init__(properties=properties, *args, **kwargs) 
    37  
    3836        cn = self._conn 
    3937        if cn: 
     
    4543            self.createCursor() 
    4644 
    47  
    4845        # We need to make sure the cursor is created *before* the call to 
    4946        # initProperties() 
    5047        self._initProperties() 
     48        super(dBizobj, self).__init__(properties=properties, *args, **kwargs) 
    5149        self._afterInit() 
    5250        self.__att_try_setFieldVal = True 
     
    721719        is built. 
    722720        """ 
    723         if self.DataSource and self.LinkField
     721        if self.DataSource and self.LinkField and self.Parent
    724722            if self.Parent.IsAdding: 
    725723                # Parent is new and not yet saved, so we cannot have child records yet. 
  • branches/uwe/dabo/dApp.py

    r2840 r2856  
    291291 
    292292 
     293    def getLoginInfo(self, message=None): 
     294        """Return the user/password to dSecurityManager.login(). 
     295 
     296        The default is to display the standard login dialog, and return the  
     297        user/password as entered by the user, but subclasses can override to get 
     298        the information from whereever is appropriate. 
     299 
     300        Return a tuple of (user, pass). 
     301        """ 
     302        import dabo.ui.dialogs.login as login 
     303        ld = login.Login(self.MainForm) 
     304        ld.setMessage(message) 
     305        ld.show() 
     306        user, password = ld.user, ld.password 
     307        return user, password 
     308     
     309     
    293310    def _persistMRU(self): 
    294311        """Persist any MRU lists to disk.""" 
  • branches/uwe/dabo/dSecurityManager.py

    r1482 r2856  
    1818                message = _("Login incorrect, please try again. (%s/%s)") % ( 
    1919                        attempt+1, self.LoginAttemptsAllowed) 
    20             user, password = self.Application.uiApp.getLoginInfo(message) 
     20            user, password = self.Application.getLoginInfo(message) 
    2121 
    2222            if user is None: 
  • branches/uwe/dabo/db/dConnectInfo.py

    r2445 r2856  
    4747        self._host = self._user = self._password = self._dbType = self._database = self._port = self._name = "" 
    4848        super(dConnectInfo, self).__init__(**kwargs) 
    49         if connInfo:    
     49        if connInfo: 
    5050            self.setConnInfo(connInfo) 
    5151 
     
    8181                connDict = cd[nm] 
    8282         
    83         # They passed a dictionary containing the connection settings 
    84         if connDict.has_key("name"): 
    85             self.Name = connDict["name"] 
    86         if connDict.has_key("dbtype"): 
    87             self.DbType = connDict["dbtype"] 
    88         if connDict.has_key("host"): 
    89             self.Host = connDict["host"] 
    90         if connDict.has_key("user"): 
    91             self.User = connDict["user"] 
    92         if connDict.has_key("password"): 
    93             self.Password = connDict["password"] 
    94         if connDict.has_key("plaintextpassword"): 
    95             self.PlainTextPassword = connDict["plaintextpassword"] 
    96         if connDict.has_key("database"): 
    97             self.Database = connDict["database"] 
    98         if connDict.has_key("port"): 
    99             try: 
    100                 self.Port = int(connDict["port"]) 
    101             except ValueError: 
    102                 # No valid port given 
    103                 self.Port = None 
     83        # Run through the connDict, and set the appropriate properties. If it isn't 
     84        # a valid property name, raise TypeError. 
     85        mapping = {"name": "Name", "dbtype": "DbType", "host": "Host", 
     86                "user": "User", "password": "Password", "database": "Database",  
     87                "plaintextpassword": "PlainTextPassword", "port": "Port"} 
     88        for k, v in connDict.items(): 
     89            prop = mapping.get(k, None) 
     90            if prop: 
     91                setattr(self, prop, v) 
     92            else: 
     93                raise TypeError, "Property '%s' invalid." % k                
    10494     
    10595     
     
    226216        return self._port 
    227217         
    228     def _setPort(self, port):  
    229         self._port = port 
     218    def _setPort(self, port): 
     219        try: 
     220            self._port = int(port) 
     221        except: 
     222            self._port = None        
    230223 
    231224 
  • branches/uwe/dabo/db/dConnection.py

    r2385 r2856  
    2121        if isinstance(connectInfo, dConnectInfo): 
    2222            self._connectInfo = connectInfo 
     23        elif connectInfo: 
     24            # If they passed a cnxml file, or a dict containing valid connection info,  
     25            # this will work fine. Otherwise, an error will be raised in the  
     26            # dConnectInfo class. 
     27            self._connectInfo = dConnectInfo(connInfo=connectInfo) 
    2328        else: 
    24             # If they passed a cnxml file, or a dict containing  
    25             # valid connection info, this will work fine. Otherwise, 
    26             # an error will be raised in the dConnectInfo class. 
    27             self._connectInfo = dConnectInfo(connInfo=connectInfo) 
     29            raise TypeError, "dConnectInfo instance or kwargs not sent." 
    2830        self._connection = self._openConnection() 
    2931         
  • branches/uwe/dabo/db/dCursorMixin.py

    r2848 r2856  
    19131913    def oldVal(self, fieldName, row=None): 
    19141914        """Returns the value of the field as it existed after the last requery.""" 
     1915        if self.RowCount < 1: 
     1916            raise dabo.dException.NoRecordsException 
    19151917        if row is None: 
    19161918            row = self.RowNumber 
  • branches/uwe/dabo/ui/uiwx/uiApp.py

    r2648 r2856  
    796796         
    797797     
    798     def getLoginInfo(self, message=None): 
    799         """ Display the login form, and return the user/password  
    800         as entered by the user. 
    801         """ 
    802         import dabo.ui.dialogs.login as login 
    803         ld = login.Login(self.dApp.MainForm) 
    804         ld.setMessage(message) 
    805         ld.show() 
    806         user, password = ld.user, ld.password 
    807         return user, password 
    808      
    809      
    810798    def _getActiveForm(self): 
    811799        if self._platform == "Win":