Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
-1
Start Page
Index
History
Editing TracDev/DataModels
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
= Trac Data Models = The main models that developers might be interested in are Ticket and !WikiPage. The constructors each take the environment as the first parameter, and the ticket id or wiki page name next. == Ticket == Data Model - [source:/trunk/trac/ticket/model.py trac.ticket.model.Ticket] '''Example:''' {{{ #!python from trac.env import Environment from trac.ticket.model import Ticket env = Environment('/path/to/trac/env') # Create a new ticket: tkt = Ticket(env) tkt['reporter'] = 'me' tkt['summary'] = 'my new ticket' tkt['description'] = 'some bogus description' tkt['status'] = 'new' tkt.insert() # To read an existing ticket pass its id to the constructor: tkt = Ticket(env, 1) print tkt['priority'] # Update another ticket: tkt = Ticket(env, 2) tkt['status'] = 'closed' tkt['resolution'] = 'fixed' tkt.save_changes(author='me', comment='programmatically closed a ticket') # And finally deleting: tkt = Ticket(env, 3) tkt.delete() }}} For more examples, see [source:/trunk/trac/ticket/web_ui.py trac.ticket.web_ui]. == !WikiPage == Data Model - [source:/trunk/trac/wiki/model.py trac.wiki.model.WikiPage] '''Example:''' {{{ #!python from trac.env import Environment from trac.wiki.model import WikiPage env = Environment('/path/to/trac/env') # Read an existing or new WikiPage: page = WikiPage(env, 'MyWikiPage') # Check if this is a new page: print page.exists # Update the content: page.text = 'page content goes here' page.save(author='me', comment='I can edit the Wiki!', remote_addr='127.0.0.1') # Read a specific page version: page = WikiPage(env, 'TracFaq', 1) print page.text # Delete a page: page = WikiPage(env, 'BadWikiPage') page.delete() # Or delete only a specific version of a page: page = WikiPage(env, 'AnotherPage') page.delete(version=5) }}} For more examples, see [source:/trunk/trac/wiki/web_ui.py trac.wiki.web_ui]. ---- See also: TracDev
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.