~ubuntu-branches/debian/squeeze/desktopcouch/squeeze

« back to all changes in this revision

Viewing changes to desktopcouch/records/server.py

  • Committer: Bazaar Package Importer
  • Author(s): David Paleino
  • Date: 2010-03-04 19:11:48 UTC
  • mfrom: (1.5.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20100304191148-zcwp3rffruwkalvc
Tags: 0.6.2-1
* New upstream version
* debian/patches/01-use_simplejson.patch removed, better handled
  upstream (simplejson for py2.5 and json for py2.6)
* debian/rules: chmod desktop-stop to 755, since it's intended as
  an executable script
* debian/control: bump debhelper dependency to >= 7.0.50~ to use
  overridden rules in debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
import urlparse
29
29
 
30
30
class OAuthCapableServer(Server):
31
 
    def __init__(self, uri, oauth_tokens=None):
 
31
    def __init__(self, uri, oauth_tokens=None, ctx=None):
32
32
        """Subclass of couchdb.client.Server which creates a custom
33
33
           httplib2.Http subclass which understands OAuth"""
34
34
        http = server_base.OAuthCapableHttp(scheme=urlparse.urlparse(uri)[0])
35
35
        http.force_exception_to_status_code = False
 
36
        if ctx is None:
 
37
            ctx = desktopcouch.local_files.DEFAULT_CONTEXT
36
38
        if oauth_tokens is None:
37
 
            oauth_tokens = desktopcouch.local_files.get_oauth_tokens()
 
39
            oauth_tokens = desktopcouch.local_files.get_oauth_tokens(ctx)
38
40
        (consumer_key, consumer_secret, token, token_secret) = (
39
41
            oauth_tokens["consumer_key"], oauth_tokens["consumer_secret"], 
40
42
            oauth_tokens["token"], oauth_tokens["token_secret"])
45
47
    """An small records specific abstraction over a couch db database."""
46
48
 
47
49
    def __init__(self, database, uri=None, record_factory=None, create=False,
48
 
                 server_class=OAuthCapableServer, oauth_tokens=None):
 
50
                 server_class=OAuthCapableServer, oauth_tokens=None,
 
51
                 ctx=desktopcouch.local_files.DEFAULT_CONTEXT):
49
52
        if not uri:
50
 
            desktopcouch.find_pid()
51
 
            port = desktopcouch.find_port()
 
53
            port = desktopcouch.find_port(ctx=ctx)
52
54
            uri = "http://localhost:%s" % port
53
55
        super(CouchDatabase, self).__init__(
54
56
                database, uri, record_factory=record_factory, create=create,
55
 
                server_class=server_class, oauth_tokens=oauth_tokens)
 
57
                server_class=server_class, oauth_tokens=oauth_tokens, ctx=ctx)