copy_objects#

ADR.copy_objects(object_type: Session | Dataset | type[Item] | type[Template], target_database: str, *, query: str = '', target_media_dir: str | Path = '', test: bool = False) int#

Copy ADR objects (and associated media) between databases.

This method:

  • Queries objects of the given type from the source database (currently hard-coded to "default").

  • For Item objects, ensures their Session and Dataset are also present in the target database, creating them as needed.

  • For Template objects, only copies root templates (children are copied recursively).

  • Copies media files to a target media directory, optionally rebuilding 3D geometry files.

Parameters:
object_typetype

One of Session, Dataset, Item subclass, or Template.

target_databasestr

Django database alias to copy into.

querystr, default: “”

ADR query string used to select objects from the source DB.

target_media_dirstr or Path, default: “”

Target directory for media files, required when copying items with associated files and the target database is not SQLite.

testbool, default: False

If True, do not actually write anything; just log and return the count of objects that would be copied.

Returns:
int

Number of objects copied (or that would be copied in test mode).

Raises:
ADRException

If misconfigured (e.g. missing DB aliases, invalid media directory, non-top-level templates, or copy errors).