Class ::xo::db::Class

::xo::db::Class[i] create ... \
           [ -abstract_p (default "f") ] \
           [ -auto_save (default "false") ] \
           [ -id_column id_column ] \
           [ -name_method (default "") ] \
           [ -object_type (default "[self]") ] \
           [ -pretty_name pretty_name ] \
           [ -pretty_plural pretty_plural ] \
           [ -security_inherit_p (default "t") ] \
           [ -sql_package_name sql_package_name ] \
           [ -supertype (default "acs_object") ] \
           [ -table_name table_name ] \
           [ -with_table (default "true") ]

::xo::db::Class is a meta class for interfacing with acs_object_types. acs_object_types are instances of this meta class. The meta class defines the behavior common to all acs_object_types. The behavior common to all acs_objects is defined by the class ::xo::db::Object.
See Also:
xo::db::Object
Defined in packages/xotcl-core/tcl/05-db-procs.tcl

Class Relations

  • class: ::xotcl::Class[i]
  • superclass: ::xotcl::Class[i]
  • subclass: ::xo::db::CrClass[i], ::xo::PackageMgr[i]

Methods (to be applied on the object)

  • class_to_object_type (scripted)

     xo::db::Class[i] class_to_object_type

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl-core xotcl-core (test ) xo::db::Class proc class_to_object_type xo::db::Class proc class_to_object_type test_xotcl-core->xo::db::Class proc class_to_object_type test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test ) test_xotcl_core_tutorial_2->xo::db::Class proc class_to_object_type

    Testcases:
    xotcl_core_tutorial_2, xotcl-core
  • delete (scripted, public)

     xo::db::Class[i] delete -id id 

    Delete the object from the database

    Switches:
    -id
    (required)

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class proc delete xo::db::Class proc delete test_xotcl_core_tutorial_2->xo::db::Class proc delete

    Testcases:
    xotcl_core_tutorial_2
  • delete_all_acs_objects (scripted, public)

     xo::db::Class[i] delete_all_acs_objects -object_type object_type 

    Delete all acs_objects of the object_type from the database.

    Switches:
    -object_type
    (required)

    Partial Call Graph (max 5 caller/called nodes):
    %3

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

     xo::db::Class[i] drop_type -object_type object_type  \
        [ -drop_table drop_table ] [ -cascade_p cascade_p ]

    Drop the object_type from the database and drop optionally the table. This method deletes as well all acs_objects of the object_type from the database.

    Switches:
    -object_type
    (required)
    -drop_table
    (defaults to "f") (optional)
    -cascade_p
    (defaults to "t") (optional)

    Partial Call Graph (max 5 caller/called nodes):
    %3

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

     xo::db::Class[i] exists_in_db -id id 

    Check, if an acs_object exists in the database.

    Switches:
    -id
    (required)
    Returns:
    0 or 1

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_test_cr_items test_cr_items (test xotcl-core) xo::db::Class proc exists_in_db xo::db::Class proc exists_in_db test_test_cr_items->xo::db::Class proc exists_in_db test_test_xo_db_object test_xo_db_object (test xotcl-core) test_test_xo_db_object->xo::db::Class proc exists_in_db test_xotcl_core_tutorial_1 xotcl_core_tutorial_1 (test xotcl-core) test_xotcl_core_tutorial_1->xo::db::Class proc exists_in_db test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) test_xotcl_core_tutorial_2->xo::db::Class proc exists_in_db test_xotcl_core_tutorial_4 xotcl_core_tutorial_4 (test xotcl-core) test_xotcl_core_tutorial_4->xo::db::Class proc exists_in_db

    Testcases:
    xotcl_core_tutorial_1, xotcl_core_tutorial_2, xotcl_core_tutorial_4, test_xo_db_object, test_cr_items
  • get_class_from_db (scripted, public)

     xo::db::Class[i] get_class_from_db [ -object_type object_type ]

    Fetch an acs_object_type from the database and create an XOTcl class from this information.

    Switches:
    -object_type
    (optional)
    Returns:
    class name of the created XOTcl class

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_3 xotcl_core_tutorial_3 (test xotcl-core) xo::db::Class proc get_class_from_db xo::db::Class proc get_class_from_db test_xotcl_core_tutorial_3->xo::db::Class proc get_class_from_db ad_try ad_try (public) xo::db::Class proc get_class_from_db->ad_try

    Testcases:
    xotcl_core_tutorial_3
  • get_instance_from_db (scripted, public)

     xo::db::Class[i] get_instance_from_db [ -id id ]

    Create an XOTcl object from an acs_object_id. This method determines the type and initializes the object from the information stored in the database. The XOTcl object is destroyed automatically on cleanup (end of a connection request).

    Switches:
    -id
    (optional)
    Returns:
    fully qualified object

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_test_xo_db_object test_xo_db_object (test xotcl-core) xo::db::Class proc get_instance_from_db xo::db::Class proc get_instance_from_db test_test_xo_db_object->xo::db::Class proc get_instance_from_db test_xotcl_core_tutorial_1 xotcl_core_tutorial_1 (test xotcl-core) test_xotcl_core_tutorial_1->xo::db::Class proc get_instance_from_db test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) test_xotcl_core_tutorial_2->xo::db::Class proc get_instance_from_db db_1row db_1row (public) xo::db::Class proc get_instance_from_db->db_1row

    Testcases:
    xotcl_core_tutorial_1, xotcl_core_tutorial_2, test_xo_db_object
  • get_object_type (scripted, public)

     xo::db::Class[i] get_object_type [ -id id ]

    Return the object type for the give id.

    Switches:
    -id
    (optional)
    Returns:
    object_type, typically an XOTcl class

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_1 xotcl_core_tutorial_1 (test xotcl-core) xo::db::Class proc get_object_type xo::db::Class proc get_object_type test_xotcl_core_tutorial_1->xo::db::Class proc get_object_type test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) test_xotcl_core_tutorial_2->xo::db::Class proc get_object_type

    Testcases:
    xotcl_core_tutorial_1, xotcl_core_tutorial_2
  • get_table_name (scripted, public)

     xo::db::Class[i] get_table_name -object_type object_type 

    Get the table_name of an object_type from the database. If the object_type does not exist, the return value is empty.

    Switches:
    -object_type
    (required)
    Returns:
    table_name

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class proc get_table_name xo::db::Class proc get_table_name test_xotcl_core_tutorial_2->xo::db::Class proc get_table_name

    Testcases:
    xotcl_core_tutorial_2
  • object_type_exists_in_db (scripted, public)

     xo::db::Class[i] object_type_exists_in_db [ -object_type object_type ]

    Check, if an object_type exists in the database.

    Switches:
    -object_type
    (optional)
    Returns:
    0 or 1

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class proc object_type_exists_in_db xo::db::Class proc object_type_exists_in_db test_xotcl_core_tutorial_2->xo::db::Class proc object_type_exists_in_db test_xotcl_core_tutorial_4 xotcl_core_tutorial_4 (test xotcl-core) test_xotcl_core_tutorial_4->xo::db::Class proc object_type_exists_in_db

    Testcases:
    xotcl_core_tutorial_2, xotcl_core_tutorial_4
  • object_type_to_class (scripted)

     xo::db::Class[i] object_type_to_class

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_link_tests link_tests (test xowiki) xo::db::Class proc object_type_to_class xo::db::Class proc object_type_to_class test_link_tests->xo::db::Class proc object_type_to_class test_path_resolve path_resolve (test xowiki) test_path_resolve->xo::db::Class proc object_type_to_class test_slot_interactions slot_interactions (test xowiki) test_slot_interactions->xo::db::Class proc object_type_to_class test_test_cr_items test_cr_items (test xotcl-core) test_test_cr_items->xo::db::Class proc object_type_to_class test_test_xo_db_object test_xo_db_object (test xotcl-core) test_test_xo_db_object->xo::db::Class proc object_type_to_class

    Testcases:
    xotcl_core_tutorial_1, xotcl-core, xotcl_core_tutorial_2, test_xo_db_object, test_cr_items, xowiki_test_cases, link_tests, slot_interactions, path_resolve

Methods (to be applied on instances)

  • check_table_atts (scripted, public)

     <instance of xo::db::Class[i]> check_table_atts

    Check table_name and id_column and set meaningful defaults, if these attributes are not provided.

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class instproc check_table_atts xo::db::Class instproc check_table_atts test_xotcl_core_tutorial_2->xo::db::Class instproc check_table_atts test_xotcl_core_tutorial_3 xotcl_core_tutorial_3 (test xotcl-core) test_xotcl_core_tutorial_3->xo::db::Class instproc check_table_atts test_xotcl_core_tutorial_4 xotcl_core_tutorial_4 (test xotcl-core) test_xotcl_core_tutorial_4->xo::db::Class instproc check_table_atts

    Testcases:
    xotcl_core_tutorial_2, xotcl_core_tutorial_3, xotcl_core_tutorial_4
  • create_object_type (scripted, public)

     <instance of xo::db::Class[i]> create_object_type

    Create an acs object_type for the current XOTcl class

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class instproc create_object_type xo::db::Class instproc create_object_type test_xotcl_core_tutorial_2->xo::db::Class instproc create_object_type

    Testcases:
    xotcl_core_tutorial_2
  • drop_object_type (scripted, public)

     <instance of xo::db::Class[i]> drop_object_type \
        [ -cascade cascade ]

    Drop an acs object_type; cascde true means that the attributes are dropped as well.

    Switches:
    -cascade
    (defaults to "true") (optional)

    Partial Call Graph (max 5 caller/called nodes):
    %3

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

     <instance of xo::db::Class[i]> get_instances_from_db \
        [ -select_attributes select_attributes ] \
        [ -from_clause from_clause ] [ -where_clause where_clause ] \
        [ -orderby orderby ] [ -page_size page_size ] \
        [ -page_number page_number ] [ -initialize initialize ]

    Returns a set (ordered composite) of the answer tuples of an 'instance_select_query' with the same attributes. Note that the returned objects might by partially instantiated.

    Switches:
    -select_attributes
    (optional)
    -from_clause
    (optional)
    -where_clause
    (optional)
    -orderby
    (optional)
    -page_size
    (defaults to "20") (optional)
    -page_number
    (optional)
    -initialize
    (defaults to "true") (optional)
    Returns:
    ordered composite

    Partial Call Graph (max 5 caller/called nodes):
    %3

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

     <instance of xo::db::Class[i]> instance_select_query \
        [ -select_attributes select_attributes ] [ -orderby orderby ] \
        [ -where_clause where_clause ] [ -from_clause from_clause ] \
        [ -count on|off ] [ -page_size page_size ] \
        [ -page_number page_number ]

    Returns the SQL-query to select ACS Objects of the object_type of the class.

    Switches:
    -select_attributes
    (optional)
    attributes for the SQL query to be retrieved. if no attributes are specified, all attributes are retrieved.
    -orderby
    (optional)
    for ordering the solution set
    -where_clause
    (optional)
    clause for restricting the answer set
    -from_clause
    (optional)
    -count
    (boolean) (defaults to "false") (optional)
    return the query for counting the solutions
    -page_size
    (defaults to "20") (optional)
    -page_number
    (optional)
    Returns:
    SQL query

    Partial Call Graph (max 5 caller/called nodes):
    %3

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

     <instance of xo::db::Class[i]> instantiate_objects [ -dbn dbn ] \
        [ -sql sql ] [ -full_statement_name full_statement_name ] \
        [ -as_ordered_composite on|off ] [ -object_class object_class ] \
        [ -named_objects on|off ] \
        [ -object_named_after object_named_after ] \
        [ -destroy_on_cleanup on|off ] [ -keep_existing_objects on|off ] \
        [ -ignore_missing_package_ids on|off ] [ -initialize initialize ]

    Retrieve multiple objects from the database using the given SQL query and create XOTcl objects from the tuples.

    Switches:
    -dbn
    (optional)
    -sql
    (optional)
    The SQL query to retrieve tuples. Note that if the SQL query only returns a restricted set of attributes, the objects will be only partially instantiated.
    -full_statement_name
    (optional)
    -as_ordered_composite
    (boolean) (defaults to "true") (optional)
    return an ordered composite object preserving the order. If the flag is false, one has to use "info instances" to access the resulted objects.
    -object_class
    (defaults to "::xotcl::Object") (optional)
    specifies the XOTcl class, for which instances are created.
    -named_objects
    (boolean) (defaults to "false") (optional)
    If this flag is true, the value of the id_column is used for the name of the created objects (object will be named e.g. ::13738). Otherwise, objects are created with the XOTcl "new" method to avoid object name clashes.
    -object_named_after
    (optional)
    -destroy_on_cleanup
    (boolean) (defaults to "true") (optional)
    If this flag is true, the objects (and ordered composite) will be automatically destroyed on cleanup (typically after the request was processed).
    -keep_existing_objects
    (boolean) (defaults to "false") (optional)
    -ignore_missing_package_ids
    (boolean) (defaults to "false") (optional)
    -initialize
    (defaults to "true") (optional)
    can be used to avoid full initialization, when a large series of objects is loaded. Per default, these objects are initialized via initialize_loaded_object, when the are of type ::xo::db::Object

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xowiki_test_cases xowiki_test_cases (test xowiki) xo::db::Class instproc instantiate_objects xo::db::Class instproc instantiate_objects test_xowiki_test_cases->xo::db::Class instproc instantiate_objects ad_try ad_try (public) xo::db::Class instproc instantiate_objects->ad_try

    Testcases:
    xowiki_test_cases
  • new_persistent_object (scripted, public)

     <instance of xo::db::Class[i]> new_persistent_object \
        [ -package_id package_id ] [ -creation_user creation_user ] \
        [ -creation_ip creation_ip ] args [ args... ]

    Create a new instance of the given class, configure it with the given arguments and insert it into the database. The XOTcl object is destroyed automatically on cleanup (end of a connection request).

    Switches:
    -package_id
    (optional)
    -creation_user
    (optional)
    -creation_ip
    (optional)
    Parameters:
    args
    Returns:
    fully qualified object

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_1 xotcl_core_tutorial_1 (test xotcl-core) xo::db::Class instproc new_persistent_object xo::db::Class instproc new_persistent_object test_xotcl_core_tutorial_1->xo::db::Class instproc new_persistent_object test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) test_xotcl_core_tutorial_2->xo::db::Class instproc new_persistent_object ad_log ad_log (public) xo::db::Class instproc new_persistent_object->ad_log ad_try ad_try (public) xo::db::Class instproc new_persistent_object->ad_try

    Testcases:
    xotcl_core_tutorial_1, xotcl_core_tutorial_2
  • object_types (scripted, public)

     <instance of xo::db::Class[i]> object_types \
        [ -subtypes_first on|off ]

    Return the type and subtypes of the class, on which the method is called. If subtypes_first is specified, the subtypes are returned first.

    Switches:
    -subtypes_first
    (boolean) (defaults to "false") (optional)
    Returns:
    list of object_types

    Partial Call Graph (max 5 caller/called nodes):
    %3 test_xotcl_core_tutorial_2 xotcl_core_tutorial_2 (test xotcl-core) xo::db::Class instproc object_types xo::db::Class instproc object_types test_xotcl_core_tutorial_2->xo::db::Class instproc object_types test_xotcl_core_tutorial_4 xotcl_core_tutorial_4 (test xotcl-core) test_xotcl_core_tutorial_4->xo::db::Class instproc object_types

    Testcases:
    xotcl_core_tutorial_2, xotcl_core_tutorial_4