OpenSite/Concepts/Documents and identity: Difference between revisions

From BathAfrica Documentation
Jump to navigation Jump to search
Publish professional OpenSite help structure and learning paths
 
Connect OpenSite chapter overviews into the documentation reading flow
 
Line 44: Line 44:
[[OpenSite/Guides/First document|Practise edit, undo, redo, save and reopen.]]
[[OpenSite/Guides/First document|Practise edit, undo, redo, save and reopen.]]


<div class="os-page-nav">{{Docnav|OpenSite/Getting started|OpenSite/Guides|OpenSite/Guides|All guides}}</div>
<div class="os-page-nav">{{Docnav|OpenSite/Workspace tour|OpenSite/Concepts/Properties and units|OpenSite/Guides|All guides}}</div>
[[Category:OpenSite documentation]]
[[Category:OpenSite documentation]]

Latest revision as of 14:16, 29 October 2026

OpenSite 0.0.1 · DevelopmentSource scope and availability

Use the right identity for the operation you are performing.

Four identities

Value Purpose Lifetime
Persistent document ID Identifies saved model content Survives save/reopen
Session handle Addresses an open document instance Valid only for that live session
Object ID Identifies an object inside a document Retained by document persistence
Name and label Unique lookup name and human-readable display label Different from the object ID

Read identity explicitly

import opensite

doc = opensite.execute("document.new", {})["document"]
created = opensite.material_create_user(doc, {
    "name": "Practice steel", "family": "steel", "role": "structural_steel",
    "has_elastic": True, "elastic_pa": 210.0e9,
    "has_poisson": True, "poisson": 0.28,
    "has_mass_density": True, "mass_density": 7850.0,
    "has_thermal": True, "thermal_per_k": 1.2e-5,
})
item = doc.get_object(created["id"])
print("Persistent document:", doc.identity())
print("Session handle:", doc.session)
print("Object ID:", item.id)
print("Internal name:", item.name)
print("Display label:", item.label)
assert doc.get_object(item.name).id == item.id
opensite.material_renumber(doc, item.id, 12)
assert doc.get_object(item.id).id == item.id

Transactions and files

An accepted edit publishes a consistent revision. Undo/redo are session history. Saving writes document data, not the undo stack. Reopening returns a new live handle; do not keep using a closed one.

Next lesson

Practise edit, undo, redo, save and reopen.