On 8/5/15 8:57 PM, Jonathan Vanasco wrote:
I have 2 related classes
• ProvisionedAccess (auth policy)
• Credentials (public/private key)
ProvisionedAccess has 2 relationships:
• keyset_active -- the active keyset, identified by having an
is_active flag
• keys_all -- all historical keys
I've implemented them as below.
the problem is when generating a new keyset. i do the following (in
order)
* deactivate existing Credentials (is_active=False)
* flush
* generate new Credentials
* flush
everything is fine, until i try to stash the relationship for some
operations
* access.keyset_active = new_Credentials
* flush
this flush removes the `provisioned_access_id` from the old
Credentials, which causes an error.
I'm not sure the best way to proceed. I need to figure out a way in
which:
a- i don't generate SQL when updating that relationship. i only use it
as a utility for selects and passing around objects.
viewonly=True?
b- i let the ORM do everything
any suggestions on either approach would be appreciated. i know
nothing about cascading relationships in the ORM.
--
keyset_active = sa.orm.relationship("Credentials",
primaryjoin="and_(ProvisionedAccess.id==Credentials.provisioned_access_id,
Credentials.is_active==True)",
uselist=False
)
keys_all = sa.orm.relationship("Credentials",
primaryjoin="ProvisionedAccess.id==Credentials.provisioned_access_id",
order_by="Credentials.id.desc()"
)
--
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.