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

Class ::xo::db::Attribute

::xo::db::Attribute[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 from and acs_object.
Defined in packages/xotcl-core/tcl/05-db-procs.tcl

Class Relations

  • class: ::xotcl::MetaSlot[i]
  • superclass: ::xo::Attribute[i]
  • subclass: ::xo::db::CrAttribute[i]

Methods (to be applied on instances)

  • attribute_reference (scripted, public)

     <instance of xo::db::Attribute[i]> attribute_reference tn
    Parameters:
    tn (required)
    Returns:
    the name of a DB attribute, potentially with an alias name.

    Testcases:
    No testcase defined.
  • column_spec (scripted, public)

     <instance of xo::db::Attribute[i]> column_spec \
        [ -id_column id_column ]
    Switches:
    -id_column (optional, defaults to "false")
    Returns:
    the full SQL spec for a DB attribute, potentially containing defaults, primary key, constraints, etc.

    Testcases:
    No testcase defined.
  • create_attribute (scripted, public)

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

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

    Testcases:
    No testcase defined.
  • db_attribute_defined (scripted, public)

     <instance of xo::db::Attribute[i]> db_attribute_defined \
        [ -object_type object_type ] [ -attribute_name attribute_name ]

    One could try caching this, but be aware that this also requires proper flushing, this value cannot be considered immutable, not even per request. ns_log notice "GN: db_attribute_defined name $attribute_name type $object_type" ::xo::dc 0or1row -prepare text,text check_att { select 1 from acs_attributes where attribute_name = :attribute_name and object_type = :object_type }

    Switches:
    -object_type (optional)
    -attribute_name (optional)

    Testcases:
    No testcase defined.
  • init (scripted, public)

     <instance of xo::db::Attribute[i]> init

    Constructor of ::xo::db::Attribute. It provides defaults and creates the ACS attribute if necessary.

    Testcases:
    No testcase defined.