Forum OpenACS Development: Re: new CrClass description issue

Collapse
Posted by Stefan Sobernig on
Tim,

"and the error that i'm getting is
how should i set description var. ?"

this leds you up the garden path. I verified your declaration of
::im::product which is not supposed to work anyway, leaving aside
creating and persisting instances thereof. Find a working examples
below:

namespace eval ::im {

  ::xo::db::CrClass create ::im::Product \
    -superclass ::xo::db::CrItem \
    -id_column product_id \
    -table_name im_products \
    -pretty_name "Im Product" \
    -slots {
    ::xo::db::CrAttribute create company_id \
        -datatype integer \
        -pretty_name "Company ID" \
        -pretty_plural "Company IDs"
    ::xo::db::CrAttribute create price \
        -pretty_name "Product Price" \
        -pretty_plural "Product Prices"    
    ::xo::db::CrAttribute create delivery_time \
        -datatype date \
        -pretty_name "Product Delivery Time" \
        -pretty_plural "Product Delivery Times"    
  }

}

::im::Product create product \
  -name "New product test name" \
  -title "New product test title" \
  -description "New product test description" \
  -price 11 \
  -delivery_time "2004-10-19 10:23:54+02"

::product save_new


What are/ were the most burning issues:

1. Slot declaration in product->init(): init is performed on an
instance, i.e. an object of class ::im::product, while slots() is
class-object-specific, i.e. it can only be applied to ::im::product
directly (technically speaking, it is a per-instance method provided
by ::xotcl::Class which is inherited by ::xo::db::CrClass)

2. you got many typos in there: pretty_namne -> pretty_name,
CtAttribute -> CrAttribute

3. finally, if you want something to be a timestamp + time zone, then
you need to provide it: ::product delivery_time "2004-10-19
10:23:54+02"

cheers
//stefan