Forum OpenACS Development: calendar error with anonymous user

When trying to acces to /calendar/view with an anonymous user, you get this error message:
Query did not return any rows.
    while executing
"db_1row select_calendar {} -column_array row"
    (procedure "calendar::get" line 4)
    invoked from within
"calendar::get -calendar_id $calendar_id -array calendar"
    (procedure "calendar::personal_p" line 6)
    invoked from within
"calendar::personal_p -calendar_id [lindex [lindex [calendar::calendar_list -package_id $package_id  ] 0] 1] "
    invoked from within
"set calendar_personal_p [calendar::personal_p -calendar_id [lindex [lindex [calendar::calendar_list -package_id $package_id  ] 0] 1] ]"

I've tried to avoid the use of user_id in calendar::calendar_list proc. But I haven't achieved any good result.

<h2>My solution</h2>
What I have done is to add ad_maybe_redirect_for_registration in view.tcl

Posted by Dave Bauer on
The correct procedure to use these days is [auth::require_login]
I don't think your calendar package should be doing this.

The reason you are getting an error is that the calendar_id does not exist for the package_id you are using.

Please investigate the real source of this error. calendar::calendar_list is returning incorrect data.

Posted by Michael Cordova on
I have been testing Calendar on my box with OpenACS 5.5, AOLServer 4.5.1, Tcl 8.4.19, and PostgreSQL 8.2.11.

After installing OpenACS, I have installed Calendar 2.5.0d1 using APM "Install from repository".

The error came when an anonymous users (user_id = 0) try to see the calendar app, due to calendar::calendar_list returns an empty list, and then calendar::personal_p breaks: Query did not return any rows.

This time, I'm gonna ask here before commit any change... I have fixed that, instead of requiring login, setting the value of calendar_personal_p if there is no user logged in:

if { $user_id eq 0 } {
    set calendar_personal_p 0
} else {
    set calendar_personal_p [calendar::personal_p -calendar_id [lindex [lindex $calendar_list_aux 0] 1] ]
Posted by Dave Bauer on
Ok here is a question.

1) Is there a default calendar for that package_id? I think there should be.
2) If there isn't, why not.
3) If there is, is it readble by user_id 0, if not, why not, since the package instance obviously is publically readable.

This should help track down the real error here.


Posted by Michael Cordova on
After trying what you ask... I can say:

1) There is no a default calendar. You can create one, for the main site, by default it will be public.
2) There isn't. To have one... which name should it have?
3) Once you create one, by default it's readable by user_id 0.

Using the code Iv'e posted, the calendar works fine.