xo::db::CrAttribute method create_attribute (public)

 <instance of xo::db::CrAttribute[i]> create_attribute

Defined in packages/xotcl-core/tcl/05-db-procs.tcl

Create an OpenACS content repository attribute, if not already defined (or attribute creation is turned off for this xo::db::CrAttribute)

Testcases:
No testcase defined.
Source code:
if {!${:create_acs_attribute}} return

set object_type [${:domain} object_type]

if {$object_type eq "content_folder"} {
  # content_folder does NOT allow one to use create_attribute etc.
  return
}

#:log "check attribute ${:column_name} object_type=$object_type, domain=${:domain}"
if {![:db_attribute_defined -object_type $object_type -attribute_name ${:column_name}]} {

  #ns_log notice "GN: CrAttribute create_attribute flushes acs_attributes cache"
  nsv_unset -nocomplain acs_attributes acs_attributes

  if {![::xo::db::Class object_type_exists_in_db -object_type $object_type]} {
    ${:domain} create_object_type
  }

  ::acs::dc call content_type create_attribute  -content_type   $object_type  -attribute_name ${:column_name}  -datatype       ${:datatype}  -pretty_name    ${:pretty_name}  -column_spec    [:column_spec]

  #if {[::acs::icanuse "nsv_dict"]} {
  #  nsv_dict set acs_attributes $object_type ${:column_name} 1
  #}
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: