Hi,
I am wondering what's the best practice to implement relationship
constraints in sqlalchemy.
Example:
Let's assume we have Account (1) <---- (n)SNMPMonitor and we
want to have the following constraints:
No account can have more than 10 SNMP Monitors.
No account can have more than 5 SNMP Monitors if their
subscription level is X
No account should have more than 7 SNMP Monitors started at
the same time.
SNMPMonitor has methods like : start/stop/reload
I am wondering where is it best to implement these constraints?
I am trying to avoid having methods like start_monitor in Account so
that Account can check if this action is allowed or not. Having such a
method means I have to pass the monitor instance to start_monitor
which will eventually do monitor.start(). I feel this is dirty because
'start_monitor' should belong to 'SNMPMonitor' as a method named
'start'. Also having a method like 'add_monitor' in Account defeats
having a backref like a.monitors that allows me to do
a.monitors.append(new_monitor).
Suggestions?
Thanks,
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en.