sqlObject, problemas de encoding?

Daniel Garcia Moreno danigm en gmail.com
Jue Ene 3 21:02:47 CET 2008


Estoy trabajando con Turbogears, y utilizando SQLObject para acceder a
la base de datos, y estoy teniendo un problema a la hora de crear
usuarios.

Me da el siguiente error:
AttributeError: "class NoDefault has no attribute 'encode'"

Este es el modelo:
class User(SQLObject):
    """
    Reasonably basic User definition.
    Probably would want additional attributes.
    """
    # names like "Group", "Order" and "User" are reserved words in SQL
    # so we set the name to something safe for SQL
    class sqlmeta:
        table = 'tg_user'

    user_name = UnicodeCol(length=16, alternateID=True,
                           alternateMethodName='by_user_name')
    email_address = UnicodeCol(length=255, alternateID=True,
                               alternateMethodName='by_email_address')
    url = UnicodeCol(length=255)
    avatar = UnicodeCol(length=255)
    location = UnicodeCol(length=50, alternateMethodName='by_location')
    display_name = UnicodeCol(length=255)
    password = UnicodeCol(length=40)
    created = DateTimeCol(default=datetime.now)

    # groups this user belongs to
    groups = RelatedJoin('Group', intermediateTable='user_group',
                         joinColumn='user_id', otherColumn='group_id')

    def _get_permissions(self):
        perms = set()
        for g in self.groups:
            perms = perms | set(g.permissions)
        return perms

    def _set_password(self, cleartext_password):
        "Runs cleartext_password through the hash algorithm before
saving."
        password_hash = identity.encrypt_password(cleartext_password)
        self._SO_set_password(password_hash)

    def set_password_raw(self, password):
        "Saves the password as-is to the database."
        self._SO_set_password(password)


y este el código que me da el error:

u = User(user_name=user, email_address=email, url=url, \
        display_name=user, password=passwd, created=datetime.now())


¿Alguna idea de cómo arreglar esto?
------------ próxima parte ------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Esta parte del mensaje está firmada	digitalmente
URL: <http://mail.python.org/pipermail/python-es/attachments/20080103/aee85c55/attachment.pgp>
------------ próxima parte ------------
_______________________________________________
Lista de correo Python-es 
http://listas.aditel.org/listinfo/python-es
FAQ: http://listas.aditel.org/faqpyes


Más información sobre la lista de distribución Python-es