-
Notifications
You must be signed in to change notification settings - Fork 887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot add_route in PHASE0_CONFIG if using view derivers #2697
Comments
After a little sleuthing I've determined that the deferred discriminators are being undeferred at the start of the conflict resolution sort in I'm looking into how to fix this, but wanted to leave some notes here before going to bed. |
Ah, it occurs on a re-entrant sort (triggered by the |
I do not see a way to preserve both of these assumptions and since assumption 2 has been in place longer, I'll err toward keeping that one. It's not possible to do conflict resolution across orders AND leave some of the discriminators in a deferred state. It just doesn't work. If we break assumption 1 then it means we should only undefer / sort actions in the order we are executing and never undefer / sort actions that come in a later order. This should be possible but will require somewhat of a rewrite of the |
Crap, now I've dug too far into this. There were some traces of code in |
Spent a little while longer thinking about this - it's something I ran into while implementing the re-entrant stuff originally but missed this aspect. There are basically three options.
Unfortunately, I think option 2 is the only option as I cannot see a way to get rid of the deferred discriminator. It's solving a real problem where the discriminator itself cannot be computed until actions from an earlier order have executed. The only solution to option 3 that I can think of is to execute action A and then later when we undefer the discriminator for action B, if it ends up conflicting with the one from action A such that it has a higher priority then we have no choice but to error. The only solution to option 3 that I can think of is to execute action A and then later when we undefer the discriminator for action B, if it ends up conflicting with the one from action A such that it has a higher priority then we have no choice but to error. However if we stick with an approach like option 2 then we can just allow the author to define 2 actions with the same discriminator on different orders to kill action A(order=0) and allow action B(order=1) to execute. The only downside is that the author needs to know, in advance, for each action he wants to override, what the order is of the action. |
This feature was silently dropped in Pyramid 1.4 when deferred discriminators were added. It is re-introduced such that it's possible to override an action in order X by defining an action in order Y where Y <= X with a non-conflicting includepath. This also takes special care to avoid undeferring the discriminator for an action until the execution engine is ready to start executing actions of the same order. This gives time for required actions to execute prior, allowing the discriminator to depend on earlier actions. fixes Pylons#2697
This feature was silently dropped in Pyramid 1.4 when deferred discriminators were added. It is re-introduced such that it's possible to override an action in order X by defining an action in order Y where Y <= X with a non-conflicting includepath. This also takes special care to avoid undeferring the discriminator for an action until the execution engine is ready to start executing actions of the same order. This gives time for required actions to execute prior, allowing the discriminator to depend on earlier actions. fixes Pylons#2697
From what I can tell, if you attempt to use view derivers you cannot call
Configurator().add_route()
inside of a action whereorder=PHASE0_CONFIG
. Using the following code to reproduce:If you execute that is, you'll get an error like:
However, if you do one of:
config.add_route
inside of the action.noop=True
parameter toconfig.add_view()
.order=PHASE0_CONFIG
toorder=PHASE1_CONFIG
.Then the code will execute successfully, although I assume the third option will break if you attempt to call something that is executed in Phase 1 instead of add_route which is executed in Phase 2.
The text was updated successfully, but these errors were encountered: