Commits

Jan Brohl committed 08e5df3

user-agent mit version übertragen

Comments (0)

Files changed (3)

 @copyright: Copyright (c) 2012, Jan Brohl <janbrohl@t-online.de>. All rights reserved.
 '''
 from distutils.core import setup
+from simplerest import __version__
 
-ver = "0.1.2"
 name = "SimpleREST"
 url = "https://bitbucket.org/janbrohl/" + name.lower()
 
 setup(name=name,
-      version=ver,
+      version=__version__,
       author="Jan Brohl",
       author_email="janbrohl@t-online.de",
       url=url,

src/simplerest/__init__.py

+__version__ = "0.1.3"

src/simplerest/rest.py

 from urlparse import urljoin
 from urllib import quote, urlencode
 from simplerest.util import geturl, default_hook, CallableVirtualPath
+from simplerest import __version__ as ver
+import sys
 try:
     from json import dumps, loads, JSONDecoder
 except:
 
 
 class REST(object):
+    agentstring = "simplerest/%s (%s)" % (ver, sys.version)
     def __init__(self, basispfad, media_types=["*/*"]):
         self.basispfad = basispfad
         self.media_types = media_types
         if query_args:
             objektpfad = objektpfad + "?" + urlencode(query_args)
         s = geturl(urljoin(self.basispfad, objektpfad),
-                   headers={"Accept": ", ".join(self.media_types)})
+                   headers={"Accept": ", ".join(self.media_types), "User-Agent":self.agentstring})
         obj = self.load(s)
         if isinstance(obj, Exception):
             raise obj
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 ProjectModifiedEvent.java.
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.