Therefore I'd like to move it to tasklets.py. Now, I know lots of
people probably have code that uses @context.toplevel. I'd like to
break such code in the next NDB release and in the next SDK, because
this may be one of the last chances I have to make incompatible API
changes.
So, if you don't want your code to break with the new version, please
switch to using @ndb.toplevel *NOW*!
In fact, in general you should be using "import ndb" instead of "from
ndb import model, tasklets, context, query", and you should use the
ndb prefix instead of its submodules. So, ndb.Model,
ndb.StringProperty, ndb.OR, etc. Also please stop using FilterNode --
use GenericProperty('name') == <expr> instead of FilterNode('name',
'=', <expr>).
--
--Guido van Rossum (python.org/~guido)
Yes, that still works. (There's even an example of this in demo/main.py.)
- transaction() inside a transaction will raise an error
- get_or_insert() inside a transaction will run in that same transaction
If no transaction exists when either of these are called, the behavior
is the same.
If you must create multiple transactions, you can start them
simultaneously using the async API, or use the Context's transaction()
method (which is also async).
I'll send another reminder about this closer to the transition date.
--Guido
strange question, would it be possible to use NDB in a java controller
environment?
P
Will do, closer to the next switch.
> A transition date would also be really helpful, though. It's great the the
> API is constantly improving, but saying "make the switch NOW" doesn't have
> quite the same psychological effect as a headline saying "Breaking change
> happening on 24th(?) February". I don't even think the exact date is needed:
> a date a few days earlier should work just fine.
Good point. In general though, our release schedule is pretty
predictable (every 4 weeks) and new runtimes are always pushed out a
few days before the new SDK is announced.
>> these will create
>> new, independent transactions, which we've found out is actually not a
>> good idea.
>
>>If you must create multiple transactions, you can start them
>> simultaneously using the async API, or use the Context's transaction()
>
> I'm guessing the point is that it's a bad idea to start multiple
> transactions are different times, but starting them simultaneously should be
> okay?
That's a slight simplification, but comes close to the point:
*outside* a transaction, when you start a transaction and wait for it
to finish, the results of the transaction will be available to you
immediately. But *inside* a transaction, when you run an *independent*
transaction, the results of the latter will not be available to you --
your *current* transaction will continue to see the world as it was
when *it* started.
--Guido