backpack
index
/Users/dustin/prog/backpack/backpack.py

Interface to the Backpack API as specified at the following location:
 
    http://developer.37signals.com/backpack/
 
Example:
 
    # Get a specific Page instance.
    bp=backpack.Backpack("http://yourusername.backpackit.com/",
        "yourApiKeyAsSeenOnYourAccountPage")
    thePage=bp.page.get(23852)
 
    # Schedule a reminder for two hours from now
    bp.reminder.create("Do this",
        backpack.formatTime(backpack.getRelativeTime("later")))

 
Modules
       
datetime
exceptions
os
sys
time
urllib2
_xmlplus

 
Classes
       
__builtin__.object
Backpack
BackpackAPI
EmailAPI
ListAPI
ListItemAPI
NoteAPI
PageAPI
ExportAPI(PageAPI, ReminderAPI)
ReminderAPI
TagAPI
Page
SearchResult
exceptions.Exception
BackpackError
PageLimitExceeded

 
class Backpack(__builtin__.object)
    Interface to all of the backpack APIs.
 
* page - PageAPI object
* reminder - ReminderAPI object
* list - ListAPI object
* notes - NoteAPI object
* tags - TagAPI object
* email - EmailAPI object
* export - ExportAPI object
 
  Methods defined here:
__init__(self, url, key, debug=False)
Initialize the backpack APIs.

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x1258150>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Backpack' objects>
list of weak references to the object (if defined)
email = None
export = None
list = None
notes = None
page = None
reminder = None
tags = None

 
class BackpackAPI(__builtin__.object)
    Interface to the backpack API
 
  Methods defined here:
__init__(self, u, k, debug=False)
Get a Backpack object to the given URL and key

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x12580d0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class BackpackError(exceptions.Exception)
    Root exception thrown when a backpack error occurs.
 
  Methods defined here:
__init__(self, code, msg)
__repr__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)
__str__(...)

 
class EmailAPI(BackpackAPI)
    The backpack Email API
 
 
Method resolution order:
EmailAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a ListAPI object to the given URL and key
destroy(self, pageId, mailId)
Delete an email.
get(self, pageId, mailId)
Get an individual email from the given page.
 
(id, subject, timestamp, text)
list(self, pageId)
Get a list of the email on the given page.
 
list of (id, subject, timestamp, text)

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x12582d0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class ExportAPI(PageAPI, ReminderAPI)
    Export page API.
 
 
Method resolution order:
ExportAPI
PageAPI
ReminderAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get an Export object to the given URL and key
export(self)
Get export of all data from BackPack
 
returns (pages, reminders)

Methods inherited from PageAPI:
create(self, title)
Create a new page.
 
Returns (id, title)
destroy(self, id)
Delete a page
duplicate(self, id)
Duplicate a page, get the new (id, title)
email(self, id)
Email yourself a page.
get(self, id)
Get a given page by id.
 
Returns a Page instance.
list(self)
List all pages
 
Returns a list of (id, scope, title) tuples.
search(self, term)
Search for pages containing the term
 
Returns a list of SearchResult objects.
share(self, id, emailAddresses=[], isPublic=False)
Share this page with others.
unshare(self, id)
Unshare a page.
updateTitle(self, id, title)
Update a title

Methods inherited from ReminderAPI:
update(self, id, content, at=None)
Update the given reminder.
 
If a time is not given, only the content will be updated.

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258530>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class ListAPI(BackpackAPI)
    Backpack list API.
 
 
Method resolution order:
ListAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a ListAPI object to the given URL and key
create(self, pageId, name)
Creates a new list on the given page
 
Returns (id, name)
destroy(self, pageId, listId)
list(self, pageId)
Get a list of lists on the given page
 
list of (id, name)
update(self, pageId, listId, name)
Changes a list's name

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258150>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class ListItemAPI(BackpackAPI)
    Backpack list API.
 
 
Method resolution order:
ListItemAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a ListAPI object to the given URL and key
create(self, pageId, listId, text)
Create a new entry.
Return (id, completedBoolean, text)
destroy(self, pageId, listId, id)
Destroy an entry.
list(self, pageId, listId)
Get a list of the items on the given list.
 
list of (id, completedBoolean, text)
move(self, pageId, listId, id, direction)
Move an entry.
 
direction can be 'move_lower', 'move_higher', 
                 'move_to_top', and 'move_to_bottom'
toggle(self, pageId, listId, id)
Toggle an entry.
update(self, pageId, listId, id, text)
Update an entry.

Data and other attributes defined here:
MOVE_HIGHER = 'move_higher'
MOVE_LOWER = 'move_lower'
MOVE_TO_BOTTOM = 'move_to_bottom'
MOVE_TO_TOP = 'move_to_top'

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258350>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class NoteAPI(BackpackAPI)
    API to Backpack Notes for a page.
 
 
Method resolution order:
NoteAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a NoteAPI object to the given URL and key
create(self, pageId, title, body)
Create a new entry.
Return (id, title, timestamp, text)
destroy(self, pageId, noteId)
Delete a note.
list(self, pageId)
Get a list of the items on the given page.
 
list of (id, title, timestamp, text)
update(self, pageId, noteId, title, body)
Update a note.

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258350>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class Page(__builtin__.object)
    An individual page.
 
* Notes are in the form of (id, title, createdDate, msg).
* Links are in the form of (id, title)
* Tags are in the form of (id, name)
 
  Data and other attributes defined here:
__dict__ = <dictproxy object at 0x12582d0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'Page' objects>
list of weak references to the object (if defined)
emailAddress = None
id = None
lists = []
notes = []
tags = []
title = None

 
class PageAPI(BackpackAPI)
    Backpack page API.
 
 
Method resolution order:
PageAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a Page object to the given URL and key
create(self, title)
Create a new page.
 
Returns (id, title)
destroy(self, id)
Delete a page
duplicate(self, id)
Duplicate a page, get the new (id, title)
email(self, id)
Email yourself a page.
get(self, id)
Get a given page by id.
 
Returns a Page instance.
list(self)
List all pages
 
Returns a list of (id, scope, title) tuples.
search(self, term)
Search for pages containing the term
 
Returns a list of SearchResult objects.
share(self, id, emailAddresses=[], isPublic=False)
Share this page with others.
unshare(self, id)
Unshare a page.
updateTitle(self, id, title)
Update a title

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258390>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class PageLimitExceeded(BackpackError)
    Exception thrown when an attempt to create a page fails with a 403.
 
 
Method resolution order:
PageLimitExceeded
BackpackError
exceptions.Exception

Methods defined here:
__init__(self, msg)

Methods inherited from BackpackError:
__repr__(self)

Methods inherited from exceptions.Exception:
__getitem__(...)
__str__(...)

 
class ReminderAPI(BackpackAPI)
    Backpack reminder API.
 
 
Method resolution order:
ReminderAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a Reminder object to the given URL and key
create(self, content, at=None)
Create a reminder with the given content.
 
If a time is not given, the content is expected to start with the
+minute or +hour:minute format as specified by backpack.
destroy(self, id)
Delete a reminder
list(self)
Get a list of upcoming reminders.
 
Returns a list of (timestamp, id, message)
update(self, id, content, at=None)
Update the given reminder.
 
If a time is not given, only the content will be updated.

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x1258590>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
class SearchResult(__builtin__.object)
    An individual search result.  The object supports the ability to
retrieve its full representation based on the type of result.  Retrieving
a writeboard only returns the id at this point, because no Writeboard
API is currently supported
 
  Methods defined here:
get(self)
Returns the appropriate representation of itself based type
 
list:       Returns the result of Backpack.list.get
note:       Returns the result of Backpack.notes.list
writeboard: Returns (page id, page title, writeboard id)
email:      Returns the result of Backpack.email.get

Data and other attributes defined here:
__dict__ = <dictproxy object at 0x1258150>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'SearchResult' objects>
list of weak references to the object (if defined)
bp = None
containerId = None
pageId = None
pageTitle = None
type = None

 
class TagAPI(BackpackAPI)
    The Backpack Tags API.
 
 
Method resolution order:
TagAPI
BackpackAPI
__builtin__.object

Methods defined here:
__init__(self, u, k, debug=False)
Get a TagAPI object to the given URL and key
pagesForTag(self, tagId)
Get a list of the pages with a given tag ID.
 
return a list of (id, title)
tagPage(self, pageId, tags)
Tag a page with a list of words.

Data and other attributes inherited from BackpackAPI:
__dict__ = <dictproxy object at 0x12584f0>
dictionary for instance variables (if defined)
__weakref__ = <attribute '__weakref__' of 'BackpackAPI' objects>
list of weak references to the object (if defined)
debug = False
key = None
url = None

 
Functions
       
formatTime(t)
Format a timestamp for an API call
getRelativeTime(rel, t=None)
Get the time relative to the specified time (default to now).
 
Allowed relative terms:
 
 * fifteen - fifteen minutes from now
 * nexthour - five minutes after the beginning of the next hour
 * later - two hours from now
 * morning - 10:00
 * afternoon - 14:00
 * evening - 19:00
 * coupledays - two days from now
 * nextweek - seven days from now
parseTime(timeString)
Parse a timestamp from a backpack response.

 
Data
        TIMEFMT = '%Y-%m-%d %H:%M:%S'