Edit this page Lock this page References to this page History of this page Home Page Recent Changes Upload file attachments Search Site Administration Help Guide

dbobj

dbobj functions take an object handle provided by one of the db $db open functions and an action to perform, then the arguments for that action.

fsid

dbobj $obj fsid
Returns the fsid of this object

construction

dbobj $obj construction
???

type

dbobj $obj type
Returns the type of this object

attrs

dbobj $obj attrs
List of attributes of this object

attrtype

dbobj $obj attrtype [ATTR]
Returns the type for the specified attribute

get

dbobj $obj get [ATTR]
Returns the value of the specified attribute

gettarget

dbobj $obj gettarget [ATTR]
List of targets in specified attribute

subobjid

dbobj $obj subobjid
Returns the subobjid of this object (that's the ## part of FSID/##)

primary

dbobj $obj primary
1 if this object is the one that would be returned if you asked for it by openid $fsid or openidconstruction $fsid/-1


Example code using all features of dbobj


#!/tvbin/tivosh
## dbobj.tcl
## Run this program with a list of arguments that specify an object in 1 of 3 ways:
##   1) Full path ("/Setup")
##   2) FSID (3249)
##   3) Construction (3249/10)

proc testdbobj {obj} {
  puts "type: [dbobj $obj type]"
  puts "fsid: [dbobj $obj fsid]"
  puts "subobjid: [dbobj $obj subobjid]"
  puts "construction: [dbobj $obj construction]"
  puts "primary: [dbobj $obj primary]"
  puts "Attributes:"
  foreach attr [dbobj $obj attrs] {
    set attrtype [dbobj $obj attrtype $attr]
    if {$attrtype == "object"} {
      puts "[dbobj $obj attrtype $attr] $attr ([dbobj $obj gettarget $attr])"
    } else {
      puts "[dbobj $obj attrtype $attr] $attr ([dbobj $obj get $attr])"
    }
  }
}

set db [dbopen]
foreach obj $argv {
  RetryTransaction {
    if {[regexp {^/} $obj]} {
      puts "--------Path: $obj"
      testdbobj [db $db open $obj]
    } elseif {[regexp {^([0-9]+)/([-0-9]+)$} $obj junk fsid subobjid]} {
      puts "--------FSID/SubID: $fsid/$subobjid"
      testdbobj [db $db openidconstruction $fsid $subobjid]
    } elseif {[regexp {^([0-9]+)$} $obj junk fsid]} {
      puts "--------FSID: $fsid"
      testdbobj [db $db openid $fsid]
    } else {
      puts "--------unknown: $obj"
    }
  }
}