Difference between revisions of "TruxtonChildFileIO newchild"
Jump to navigation
Jump to search
(→Sample) |
|||
| Line 11: | Line 11: | ||
=Sample= | =Sample= | ||
| − | <source lang="Python" | + | <source lang="Python" highlight="15"> |
import truxton | import truxton | ||
| Line 34: | Line 34: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
| − | main() | + | sys.exit(main()) |
</source> | </source> | ||
Latest revision as of 10:02, 3 February 2024
This create child file object from a file in Truxton.
It automatically associates the parent file and media identifiers used in the [File] table.
Syntax
object newchild();
Return value
An child file object
Sample
import truxton
def main():
t = truxton.create()
file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
child = file.newchild()
child.name = "My Child"
child.origin = truxton.ORIGIN_GENERATED
child.write("Hello Truxton World")
if child.save() is True:
print( "New child saved as id " + child.id)
child2 = child.newchild()
child2.name = "My GrandChild"
child2.origin = truxton.ORIGIN_GENERATED
child2.write("Hello Truxton World")
if child.save() is True:
print( "New grandchild saved as id " + child.id)
if __name__ == "__main__":
sys.exit(main())