Closed POD666 closed 5 years ago
Nice idea, but not suitable in our case.
Basically, we don't want exceptions to be raised, that's why return_instead
parameter is there.
@dxvxd could you expand on why it is not suitable in your case or even in general?
My understanding of the (or simply a?) use case for this package is in the context of backwards compatible migrations. i.e. it's useful in making a field disappear from your codebase, while maintaining it in your database such that older versions of your codebase don't crash because it is missing. In fact this is the use case that's being described in the referenced blog post
In that use case, hard failure would seem perfectly acceptable to me: it most closely matches what would happen if you would have proceeded "normally" (i.e. without trying to stay backwards compatible), since in that case you would simply remove the field resulting in an AttributeError. Hard failure is also more likely to ensure that your stack trace reflects the line in which an error was made, rather than somewhere down the line.
Use case is described in blog post you mentioned: you have working deployment and you need to upgrade it to latest version. During upgrade process, while migrations are running, you don't want to raise erros and break request-response cycles of current users.
I'm not quite sure I understand what you're saying here, so let me be even more explicit in my understanding of the typical workflow to see where te misunderstanding is. As I see it, the relevant pieces here are 2 versions of the code ("old" and "new"). 2 of these may be in play at the same time on different servers, connecting to a single database.
The code proposed here would, AFAICS, not raise errors in either of these:
There is of course a third thing that comes into play, namely the running of the migrations themselves. But there no actual models are used, so this code does not come into play AFAICS.
Not sure if it matches your vision but it makes sense for me.
Here is how it looks like:
You might want to change
forbid_access
toFalse
to keep old behavior by default. Also, there might be better texts/names to be used.