Hello,

I have to follow up on this as I'm running into something that makes me
feel totally stupid.

Here's how I implemented this:

class Credential(SQLObject):
    class sqlmeta:
        # necessary for the _set_passwd magic defined below
        cacheValues = False
    username = StringCol(alternateID=True, unique=True)
    passwd = StringCol()
    def _set_passwd(self, value):
        # if the database has a built-in password hashing function,
        # use it. Otherwise, store a SHA256 password hash
        try:
            self._SO_set_passwd(func.PASSWORD(value))
        except:
            digest = SHA256.new(value).hexdigest()
            self._SO_set_passwd(digest)

So, thanks to Oleg's suggestions, this happily applies PASSWORD() when
running on MySQL. Beautiful.

However, on a platform without PASSWORD() (tried sqlite), this happens:

>>> c = Credential(username="foo", passwd="bar")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  [rest of stack trace...]
  File
"/usr/lib/python2.5/site-packages/sqlobject/sqlite/sqliteconnection.py",
line 183, in _executeRetry
    raise OperationalError(ErrorMessage(e))
sqlobject.dberrors.OperationalError: no such function: PASSWORD

Huh? I said try..except, didn't I? As I said, this makes me feel totally
braindead. Can someone whack me in the head and point me to the obvious
thing I am missing?

Cheers,
Florian

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to