Commits

Jan Brohl committed 08e5df3

user-agent mit version übertragen

  • Participants
  • Parent commits 9056edb

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,

File src/simplerest/__init__.py

+__version__ = "0.1.3"

File 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