[Cl-perec-devel] Lots of questions :-)
attila.lendvai at gmail.com
Mon Sep 14 10:40:08 UTC 2009
> (cl-perec:defptype password ()
> '(text 128))
> (cl-perec::defmapping password (cl-rdbms::sql-character-varying-type :size 128)
> 'cl-perec:identity-reader ; unexported
> (defun password-writer (val rdbms-values index)
> (setf (elt rdbms-values index)
> (ironclad:digest-sequence :sha1 (babel:string-to-octets val)))))
i'm not sure you want to do this, though... this will apply the hash
algorithm every time the slot is *written* to the db.
what you want is a setf customization on the password slot that gets
triggered every time the slot is *set*. but it requires a custom
metaclass, etc... imho, not really worth it.
i suggest to use a simple (defun update-password ...) custom function instead.
*if* your password was stored with a reversible encrypting, then this
solution could work if you also decrypt the slot value in the reader
function of the type.
btw, we have our relevant code here:
> (pushnew 'password cl-perec::*mapped-type-precedence-list*)
read the docs on the above variable. you need to append your type at
the end, not the beginning...
More information about the cl-perec-devel