%3 ::xo::db::CrAttribute ::xo::db::CrAttribute create_attribute ::xo::db::Attribute ::xo::db::Attribute attribute_reference column_spec create_attribute db_attribute_defined init ::xo::db::CrAttribute->::xo::db::Attribute ::xo::Attribute ::xo::Attribute init ::xo::db::Attribute->::xo::Attribute ::xotcl::Attribute ::xotcl::Attribute ::xo::Attribute->::xotcl::Attribute

Class ::xo::db::CrAttribute

::xo::db::CrAttribute[i] create ... \
           [ -column_name column_name ] \
           [ -constraint_values constraint_values ] \
           [ -create_acs_attribute:substdefault (default "true") ] \
           [ -create_table_attribute:substdefault (default "true") ] \
           [ -datatype:substdefault (default "text") ] \
           [ -help_text help_text ] \
           [ -index index ] \
           [ -max_n_values:substdefault (default "1") ] \
           [ -min_n_values:substdefault (default "1") ] \
           [ -multivalued multivalued ] \
           [ -not_null not_null ] \
           [ -pretty_name pretty_name ] \
           [ -pretty_plural:substdefault (default "") ] \
           [ -references:substdefault (default "") ] \
           [ -required:substdefault (default "false") ] \
           [ -spec spec ] \
           [ -sqltype sqltype ] \
           [ -substdefault substdefault ] \
           [ -unique unique ] \
           [ -validator validator ]

ORM class representing an acs_attribute for a content_type in the Content Repository.
Defined in packages/xotcl-core/tcl/05-db-procs.tcl

Class Relations

  • class: ::xotcl::MetaSlot[i]
  • superclass: ::xo::db::Attribute[i]
::xotcl::MetaSlot create ::xo::db::CrAttribute \
     -superclass ::xo::db::Attribute

Methods (to be applied on instances)

  • create_attribute (scripted)

    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
      #}
    }