[doc] Re: [turba] turning attention to undefined indices

Chuck Hagenbuch chuck at horde.org
Sun Nov 2 10:07:01 PST 2003


[cc:ing the doc list on this in case someone is inspired to turn it into
something postable/included in the Turba docs.]

Quoting "Eric S. Johansson" <esj at harvee.org>:

> >>> Notice: Undefined index: businesscategory in
> >>> /var/www/html/horde/turba/templates/browse/search.inc on line 14
> >
> >
> > These are not database errors.
>
> they aren't?  Well that makes me feel like a goldplated fool.  I spend
> most of my time in Python and this kind error (KeyError) comes up on
> database problems as well so I made a bad assumption.  When I searched
> the Web for solutions to this problem, I found lots of unanswered
> requests for similar issues.

Well, mostly those requests were answered by telling people to fix their
configuration files, since the root of the problem is that two of your config
files don't match up.

However, for posterity, the lists, etc., here's what's going on.

Turba has a system of defining what is in a directory/addressbook/whatever you
want to call it that is necessarily complicated by reason that it is flexible
enough to map to pretty much anything with zero code changes, only config
tweaks.

In config/sources.php, for every backend that you use in Turba, you configure a
"map". The map defines a mapping between whatever fields exist in the backend,
and what Turba calls those fields and also what kind of data Turba treats them
as. So if the contact_email field in a database table is an email address, you
could tell Turba to map 'email' => 'contact_email'. In CVS HEAD, btw, you can
also tell turba that 'name' is a composite of 'contact_firstname' and
'contact_lastname', and also tell it how to format those fields together with a
sprintf-style string. But that's not the point right now.

The next leap is, how does Turba know what 'email' or 'name' are? They're
defined in config/attributes.php, which is the set of attributes that any given
Turba install understands. attributes.php defines the label for a field and
what kind of data it is - a string, an email address, an enumeration of several
options, etc.

So, back to your problem: you have some attributes in your map that Turba
doesn't know about. In sources.php, there's probably a line:

    'businesscategory' => 'backend_field_bus_cat',

... or whatever the backend field is. But there's not 'businesscategory'
attribute in attributes.php. You need to either add an attribute entry, or
remove that field, or map it to something else that Turba already knows about.

Is this a problem with the default config files, you're going to ask me? Well,
yes - for a while, the default sources.php included an example that used
attributes that weren't in the default attributes.php. This has since been
fixed, but it was possibly after the last stable release.

Why isn't it in the documentation somewhere, you ask? Well, the comments at the
top of the two files in question try to document it, but basically because no
one had the time to try and write something like this up, make sure it was
understandable (which it still might not be), and put it somewhere useful. I'm
still actually not sure where it should live - probably on the Turba website, I
guess.

So, hope that helps.

-chuck

--
Charles Hagenbuch, <chuck at horde.org>
Born right the first time.


More information about the doc mailing list