After all testing, i got it working, but im not very satisfied with my
solution. It requires looping thru countrys post offices and post
numbers and finding if address exists. Here is code to compare with
previous examples. Maybe you can say, whats the difference and how it
could be done more clever:

class User():

def set_default_address_by_name(self, name, post_office_name,
post_number_name, country):
        has_default = False
        for address in self.addresses:
            address.is_default = False
            if address.name == name and address.post_office.name ==
post_office_name and address.post_number.name == post_number_name:
                address.is_default = True
                has_default = True
        if not has_default:
            post_office = False
            post_number = False
            for post_office in country.post_offices:
                if post_office.name == post_office_name:
                    break
            if not post_office or post_office.name !=
post_office_name:
                post_office = PostOffice(country=country,
name=post_office_name)
                for post_number in post_office.post_numbers:
                    if post_number.name == post_number_name:
                        break
            if not post_number or post_number.name !=
post_number_name:
                post_number = PostNumber(post_office=post_office,
name=post_number_name)

            self.addresses.append(UserAddress(name=name,
post_office=post_office, post_number=post_number, is_default = True))

Now password is not updated as it was earlier when i flush session.

-Marko

On Feb 21, 5:01 pm, Jonathan LaCour <[EMAIL PROTECTED]>
wrote:
> mmstud wrote:
> > When updating model, i see password is encrypted and updated as
> > well even i dont change it and in my case encrypted pass gets
> > encrypted, and next time over and over again, so password changes
> > and string gets longer and longer. What might cause this and how
> > it is prevented?
>
> I cannot reproduce your problem in my testing.  It seems to work
> fine for me.  Can you provide more details?  What version of
> SQLAlchemy are you using?  What version of Elixir?  Are you using
> the default session included with Elixir, and if not how are you
> creating and configuring your session?
>
> --
> Jonathan LaCourhttp://cleverdevil.org
--~--~---------~--~----~------------~-------~--~----~
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