Forum OpenACS Q&A: Response to Problems with Enhanced-News package

Collapse
Posted by Esti Alvarez on
This is something that looks pretty much like the procedure I want to make work:
proc news_get_user_priviledge {user_id } {
    db_with_3x_wrapper {
        if [ad_administrator_p $db $user_id] {
            return "Post"
        }
    }
 
    set priviledge ""
    db_foreach check_priviledge "
    select group_id
    from newsgroups
    where enabled_p = 't'" {
        db_with_3x_wrapper { 
          set member_p [ad_user_group_member $db $group_id $user_id]
	  }
        if $member_p {
            set priviledge "Suggest"
        }
    }
    return $priviledge
}

ReturnHeaders
 
set result [news_get_user_priviledge2 1]
 
ns_write "$result"

Works for user_id > 1 but user_id=1 returns:

Error: could not allocate 1 handle from pool "whatever"
could not allocate 1 handle from pool "whatever"
    while executing
"ns_db gethandle whatever"
    (procedure "db_with_3x_wrapper" line 4)
    invoked from within
"db_with_3x_wrapper {
          set member_p [ad_user_group_member $db $group_id $user_id]
          }"
    ("uplevel" body line 2)
    invoked from within
"uplevel 1 $code_block "
    ("1" arm line 1)
    invoked from within
"switch $errno {
                0 {
                    # TCL_OK
                }
                1 {
                    # TCL_ERROR
                    global errorInfo errorCode
                    error $error $errorInfo $errorCode
                }
                2 {
        ..."
    ("while" body line 20)
    invoked from within
"while { [db_getrow $db $selection] } {
            incr counter
            if { [info exists array_val] } {
                unset array_val
            }
            if { ![info exists column..."
    ("uplevel" body line 5)
    invoked from within
"uplevel 1 $code_block "
    invoked from within
"db_with_handle db {
        set selection [db_exec select $db $statement_name $sql]

        set counter 0
        while { [db_getrow $db $selection] } {
            incr counter..."
    (procedure "db_foreach" line 32)
    invoked from within
"db_foreach check_priviledge "
    select group_id
    from newsgroups
    where enabled_p = 't'" {
        db_with_3x_wrapper {
          set member_..."
    (procedure "news_get_user_priviledge" line 9)
    invoked from within
"news_get_user_priviledge 1"
    invoked from within
"set done [news_get_user_priviledge 1]"
    (file "/web/hezkuntza/www/enhanced-news/example2.tcl" line 27)
    invoked from within
"source $script"
    (procedure "ns_sourceproc" line 6)
    invoked from within
"ns_sourceproc cns1 {}"