Anonymous avatar Anonymous committed 31d3554

fix basic auth & issue #31.

Comments (0)

Files changed (3)


 from django.db.models import signals, get_app
 from django.core.exceptions import ImproperlyConfigured
 from django.utils.datastructures import SortedDict
-from restclient.transport import getDefaultHTTPTransport
+from restkit.httpc import ProxiedHttpClient, BasicAuth
         self.__dict__ = self.__shared_state__
         if transport is None:
-            self.transport = getDefaultHTTPTransport()
+            self.transport = ProxiedHttpClient()
         # create databases sessions
         for app_name, uri in databases:
-            parts = urlparse.urlsplit(urllib.unquote(uri))
+            if isinstance(uri, tuple):
+                # case when you want to specify server uri 
+                # and database name specifically. usefull
+                # when you proxy couchdb on some path 
+                server_part, dbname = uri
+                parts = urlparse.urlsplit(urllib.unquote(server_part))
+            else:
+                parts = urlparse.urlsplit(urllib.unquote(uri))
+                dbname = parts[2].split("/")[1]
             if parts[0] != 'http' and parts[0] != 'https':
                 raise ValueError('Invalid dbstring')
-            dbname = parts[2].split("/")[1]
             if "@" in parts[1]:
                 server_parts = parts[1].split('@')
                 if ":" in server_parts[0]:
                 username = password = ""
             if username:
-                self.transport.add_credentials(username, password)
+                self.transport.add_authorization(BasicAuth(username, password))
             server = Server(server_uri, self.transport)
             app_label = app_name.split('.')[-1]
             self._databases[app_label] = create_session(server, dbname, local)


 class Greeting(Document):
     author = StringProperty()
     content = StringProperty(required=True)
-    date = DateTimeProperty(default=datetime.utcnow)
+    date = DateTimeProperty(default=datetime.utcnow)


     class Meta:
         document = Greeting
 def home(request):
     greet = None
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.