Edgewall Software

Trac Database Schema: Common

Trac stores common authentication, caching, permission, session and system information in the database that is not specific to a certain module.

Table system


Stores some system properties.

Trac itself only uses this table for managing database upgrades. It initializes this table with the following data during installation or upgrades:

database_versionThe (upgraded) DB version
initial_database_versionThe DB version

These values can be accessed using env.get_version() and env.get_version(initial=True) where env is an instance of trac.env.Environment (e.g. self.env in a Component.)

(In earlier Trac versions, there were additional properties named repository_dir and youngest_rev. These are now part of the VcCache.)

See trac.env.Environment

Table permission

permissionusername, action

Stores TracPermissions (and TracFineGrainedPermissions).

If action is not all uppercase, it actually stores a permission group name. (username might store a permission group name in both cases.) This table should be used via the permission cache that can be used to check the permissions of the relevant user (both for performance and correctness reasons, e.g. other permission group providers etc. would be sidestepped otherwise.) That permission cache is for example available as req.perm for request handlers, or as formatter.perm for wiki macros.

During installation Trac initializes this table with some default permissions for the anonymous user and the authenticated group.

See trac.perm.DefaultPermissionStore

auth_cookiecookie, ipnr, name
cookie Value of the cookie (32 random hex digits)
name User name authenticated by this cookie
ipnr IP address of the user
timeintLast time of authentication

Stores authentication credentials of users. The trac_auth cookie identifies the entry of a authenticated user in this table.

See trac.web.auth.LoginModule, TracDev/TracSession

Table session

sessionsid, authenticated
sid Session ID
authenticatedint1 for authenticated sessions, 0 for anonymous sessions
last_visitintTime of last visit of this session's user

See trac.web.session, TracDev/TracSession

Table session_attribute

session_attributesid, authenticated, name
sid Session ID
authenticatedint1 for authenticated sessions, 0 for anonymous sessions
name Name of some attribute stored for that session
value Value of that attribute

This table can be managed using the Session object, which is usually available as req.session.

Trac itself uses session attributes to store various configuration settings, e.g.:

  • Preferences
    • name, email
    • tz, dateinfo, lc_time
    • accesskeys
    • language
    • pygments_style
  • Wiki editing settings
    • wiki_sidebyside
    • wiki_editrows
    • wiki_fullwidth
  • Timeline settings
    • timeline.lastvisit, timeline.nextlastvisit
    • timeline.daysback
    • timeline.authors *timeline.filter.*
  • Ticket settings
    • ticket_comments_order, ticket_comments_only
  • Ticket Query settings
    • query_href
    • query_tickets
    • query_time
    • query_constraints
  • Diff settings
    • diff_style
    • diff_contextlines

See trac.web.session, TracDev/TracSession

Table cache

idintIdentifies a certain property to be cached
generationintCurrent generation of this cached property
key Usually the class-qualified name of the cached property

Use the CacheManager component e.g. via the cached_value decorator to cache values (in process or thread-local memory). This table is used to manage (e.g., correctly invalidate) these caches.

See trac.cache, TracDev/CacheManager

Last modified 7 months ago Last modified on Feb 21, 2022, 8:51:44 PM
Note: See TracWiki for help on using the wiki.