Hi All,

I am fairly new to python/SA/Elixir,  a month to be exact.
I am getting this undesirable effect - My Password Field is being
modified during update by something.

Overview:
If a user is Inactive then the Inactive Field is True and the
InactiveBy will be the user who flagged it as Inactive. Otherwise
Inactive = False and InactiveBy = None

It is from Inactive = True to Inactive = False that the Password Field
is being modified

What I am doing wrong.

Thanks in Advance,

Below is a minimal example to reproduce it (in postgres too)
----------------------------------------------------------------------------------------------------------
#!/usr/local/bin/python2.6
from elixir import metadata, session, setup_all
metadata.bind = "sqlite:///:memory:"
metadata.bind.echo = False

from elixir import (Entity, Field, using_options, String, Boolean,
ManyToOne)
from elixir.ext.encrypted import acts_as_encrypted

class User(Entity):
    using_options(tablename="user")
    UserId = Field(String(16))
    Password = Field(String(128))
    Inactive = Field(Boolean, default=False)
    InactiveBy = ManyToOne("User")
    acts_as_encrypted(for_fields=["Password"],with_secret="pogi")

    def __repr__(self):
        return '<User "%s", "%s", "%s", "%s">' % (self.UserId, self.Password,
self.Inactive,
                                            (self.InactiveBy.UserId if
self.InactiveBy is not None else None))

if __name__ == "__main__":
    # setup
    setup_all(True)
    # create user root
    table = User(UserId="root",Password="root")
    session.commit()
    session.clear()
    # create user gvv
    table = User(UserId="gvv",Password="gvv")
    session.commit()
    session.clear()
    # create user ljv
    table = User(UserId="ljv",Password="ljv")
    session.commit()
    session.clear()
    # query all
    print "Initial records"
    rows = User.query.all()
    print rows
    # update gvv as inactive by root
    print "update gvv as inactive by root"
    me = User.get_by(UserId="root")
    session.clear()
    table = User.get_by(UserId="gvv")
    if table is not None:
        table.Inactive = True
        table.InactiveBy = me
        session.commit()
    session.clear()
    # query all
    rows = User.query.all()
    print rows
    # update gvv as active by root -- gvv password has been modified
    print "update gvv as active by root"
    me = User.get_by(UserId="root")
    session.clear()
    table = User.get_by(UserId="gvv")
    if table is not None:
        table.Inactive = False
        table.InactiveBy = None
        session.commit()
    session.clear()
    # query all
    rows = User.query.all()
    print rows
    # update gvv as inactive by ljv
    print "update gvv as inactive by ljv"
    me = User.get_by(UserId="ljv")
    session.clear()
    table = User.get_by(UserId="gvv")
    if table is not None:
        table.Inactive = True
        table.InactiveBy = me
        session.commit()
    session.clear()
    # query all
    rows = User.query.all()
    print rows

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to