moo.core.moojson

Encode/decode MOO JSON.

This module is also the registered Celery task serializer (moojson in celeryconfig.py), not just the storage format for Property.value. Anything that crosses a Celery boundary — task args, kwargs, results, invoke_verb payloads queued from transaction.on_commit — round-trips through dumps and loads. Two consequences flow from this:

  1. loads runs before the worker’s ContextManager is entered. Logic that reads ContextManager.get_site() must tolerate None and not silently rewrite refs against the default site, or every cross-site Object arg gets clobbered to $nothing on its way into a task.

  2. Anything that goes into Property.value also travels through Celery, so the two encodings must stay reversible without a site context.

Functions

clear_nothing_cache()

Reset the $nothing object cache (call between tests that reset the DB).

dumps(obj)

filter_nothing(value)

Remove $nothing sentinel entries from list property values.

loads(j)

replace_object_refs(j, old_pk, new_obj)

Return a new JSON string with all {"o#<old_pk>": ...} references replaced by a reference to new_obj.