python-fedora: Refactoring of variable and parameter names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With some prompting from lmacken, I've just committed the attached patch to python-fedora-devel. This brings the names of variables used in python-fedora into conformance with PEP8. However, it does cause breakage in public instance and class variables as well as the parameter names. Since this is destined for 0.3 which has incompatible changes, this is the time for these changes.

If this is considered too much of a problem to port apps to for a cosmetic change, please holler now so we can revert before too many other changes accumulate on top of this.

Also note, I've started compiling a list of incompatibilities between 0.2.99.11.1 and what will be 0.3. These are listed below and will be replicated in the NEWS file shortly.

* Removal of camelCase. Rename keyword arguments and public instance variables:
  * client.BaseClient
    *Note* that changes to this class propogate out to the same variable in
    derived classes like fas2.AccountSystem and the BaseClient used in
    JsonFasIdentity.
    * __init__(): baseURL => base_url
* _sessionCookie => _session_cookie: this is a private variable but some
      users use this anyway.  For users needing to access this, there's now
      a more appropriate class for doing so (ProxyClass).
  * accounts.fas2.AccountSystem
    * group_by_id(): groupId => group_id
    * person_by_id(): personId => person_id
  * tg.widgets
    * All widgets had widgetId => widget_id
    * Also means accessing the variable is done via self.widget_id
  * tg.json.SABase
    * self.jsonProps => self.json_props
* BaseClient.send_request() has keyword argument input renamed to req_params
* Restructuring of Exceptions in BaseClient
  * New base exception is FedoraServiceError if you want to catch that.
* Rename accounts.fas2.AccountSystem.authenticate() to verify_password()

-Toshio
=== modified file 'fedora/accounts/fas2.py'
--- fedora/accounts/fas2.py	2008-06-01 20:43:05 +0000
+++ fedora/accounts/fas2.py	2008-06-04 00:23:29 +0000
@@ -39,10 +39,10 @@
     other details so you can concentrate on the methods that are important to
     your program.
     '''
-    def __init__(self, baseURL='https://admin.fedoraproject.org/accounts/',
+    def __init__(self, base_url='https://admin.fedoraproject.org/accounts/',
             username=None, password=None, debug=False):
-        super(AccountSystem, self).__init__(baseURL=baseURL, username=username,
-                password=password, debug=debug)
+        super(AccountSystem, self).__init__(base_url=base_url,
+                username=username, password=password, debug=debug)
         # Preseed a list of FAS accounts with bugzilla addresses
         # This allows us to specify a different email for bugzilla than is
         # in the FAS db.  It is a hack, however, until FAS has a field for the
@@ -90,8 +90,8 @@
                 # Kevin Fenzi: kevin@xxxxxxxxx
                 'kevin-redhat-bugzilla@xxxxxxxxx': 100037,
                 }
-        for bugzillaMap in self.__bugzilla_email.items():
-            self.__alternate_email[bugzillaMap[1]] = bugzillaMap[0]
+        for bugzilla_map in self.__bugzilla_email.items():
+            self.__alternate_email[bugzilla_map[1]] = bugzilla_map[0]
 
         # We use the two mappings as follows::
         # When looking up a user by email, use __alternate_email.
@@ -102,27 +102,27 @@
         # the only option.
 
     # TODO: Use exceptions properly
-    def group_by_id(self, groupId):
+    def group_by_id(self, group_id):
         '''Returns a group object based on its id'''
-        params = {'id': int(groupId)}
+        params = {'id': int(group_id)}
         request = self.send_request('json/group_by_id', auth=True,
-                reqParams=params)
+                req_params=params)
         if request['success']:
             return request['group']
         else:
             return dict()
 
-    def person_by_id(self, personId):
+    def person_by_id(self, person_id):
         '''Returns a person object based on its id'''
-        personId = int(personId)
-        params = {'id': personId}
+        person_id = int(person_id)
+        params = {'id': person_id}
         request = self.send_request('json/person_by_id', auth=True,
-                reqParams=params)
+                req_params=params)
 
         if request['success']:
-            if personId in self.__bugzilla_email:
+            if person_id in self.__bugzilla_email:
                 request['person']['bugzilla_email'] = \
-                        self.__bugzilla_email[personId]
+                        self.__bugzilla_email[person_id]
             else:
                 request['person']['bugzilla_email'] = request['person']['email']
             return request['person']
@@ -133,7 +133,7 @@
         '''Returns a group object based on its name'''
         params = {'groupname': groupname}
         request = self.send_request('json/group_by_name', auth=True,
-                reqParams=params)
+                req_params=params)
         if request['success']:
             return request['group']
         else:
@@ -143,7 +143,7 @@
         '''Returns a person object based on its username'''
         params = {'username': username}
         request = self.send_request('json/person_by_username', auth=True,
-                reqParams=params)
+                req_params=params)
         person = request['person']
         if request['success']:
             if person['id'] in self.__bugzilla_email:
@@ -170,18 +170,18 @@
         '''
         ### FIXME: This should be implemented on the server as a single call
         request = self.send_request('/json/user_id', auth=True)
-        userToId = {}
+        user_to_id = {}
         people = {}
         for person_id, username in request['people'].items():
             person_id = int(person_id)
             # change userids from string back to integer
             people[person_id] = {'username': username, 'id': person_id}
-            userToId[username] = person_id
+            user_to_id[username] = person_id
 
         # Retrieve further useful information about the users
         request = self.send_request('/group/dump', auth=True)
         for user in request['people']:
-            userid = userToId[user[0]]
+            userid = user_to_id[user[0]]
             person = people[userid]
             person['email'] = user[1]
             person['human_name'] = user[2]
@@ -211,11 +211,11 @@
 
         Returns: True if the username/password are valid.  False otherwise.
         '''
-        asUser = BaseClient(self.baseURL, username, password)
+        as_user = BaseClient(self.base_url, username, password)
         try:
             # This will attempt to authenticate to the account system and
             # raise an AuthError if the password and username don't match. 
-            asUser._authenticate(force=True)
+            as_user._authenticate(force=True)
         except AuthError:
             return False
         except:

=== modified file 'fedora/client/__init__.py'
--- fedora/client/__init__.py	2008-06-01 20:43:05 +0000
+++ fedora/client/__init__.py	2008-06-04 00:15:36 +0000
@@ -28,7 +28,6 @@
 import urllib2
 import logging
 import cPickle as pickle
-import re
 import inspect
 import simplejson
 import os
@@ -63,11 +62,11 @@
     '''
         A command-line client to interact with Fedora TurboGears Apps.
     '''
-    def __init__(self, baseURL, username=None, password=None,
+    def __init__(self, base_url, username=None, password=None,
             useragent=None, debug=False):
         '''
         Arguments:
-        :baseUrl: Base of every URL used to contact the server
+        :base_url: Base of every URL used to contact the server
         Keyword Arguments:
         :username: username for establishing authenticated connections
         :password: password to use with authenticated connections
@@ -75,26 +74,26 @@
             "Fedora BaseClient/VERSION"
         :debug: If True, log debug information
         '''
-        if baseURL[-1] != '/':
-            baseURL = baseURL +'/'
-        self.baseURL = baseURL
+        if base_url[-1] != '/':
+            base_url = base_url +'/'
+        self.base_url = base_url
         self.username = username
         self.password = password
         self.useragent = useragent or 'Fedora BaseClient/%(version)s' % {
                 'version': __version__}
-        self._sessionCookie = None
+        self._session_cookie = None
 
         # Setup our logger
-        logHandler = logging.StreamHandler()
+        log_handler = logging.StreamHandler()
         if debug:
             log.setLevel(logging.DEBUG)
-            logHandler.setLevel(logging.DEBUG)
+            log_handler.setLevel(logging.DEBUG)
         else:
             log.setLevel(logging.INFO)
-            logHandler.setLevel(logging.INFO)
+            log_handler.setLevel(logging.INFO)
         format = logging.Formatter("%(message)s")
-        logHandler.setFormatter(format)
-        log.addHandler(logHandler)
+        log_handler.setFormatter(format)
+        log.addHandler(log_handler)
 
         self._load_session()
         if username and password:
@@ -104,20 +103,20 @@
         '''
             Return an authenticated session cookie.
         '''
-        if not force and self._sessionCookie:
-            return self._sessionCookie
+        if not force and self._session_cookie:
+            return self._session_cookie
         if not self.username:
             raise AuthError, _('username must be set')
         if not self.password:
             raise AuthError, _('password must be set')
 
-        req = urllib2.Request(urljoin(self.baseURL, 'login?tg_format=json'))
+        req = urllib2.Request(urljoin(self.base_url, 'login?tg_format=json'))
         req.add_header('User-agent', self.useragent)
         req.add_header('Accept', 'text/javascript')
-        if self._sessionCookie:
+        if self._session_cookie:
             # If it exists, send the old sessionCookie so it is associated
             # with the request.
-            req.add_header('Cookie', self._sessionCookie.output(attrs=[],
+            req.add_header('Cookie', self._session_cookie.output(attrs=[],
                 header='').strip())
         req.add_data(urllib.urlencode({
                 'user_name' : self.username,
@@ -126,29 +125,29 @@
         }))
 
         try:
-            loginPage = urllib2.urlopen(req)
+            login_page = urllib2.urlopen(req)
         except urllib2.HTTPError, e:
             if e.msg == 'Forbidden':
                 raise AuthError, _('Invalid username/password')
             else:
                 raise
 
-        loginData = simplejson.load(loginPage)
+        login_data = simplejson.load(login_page)
 
-        if 'message' in loginData:
+        if 'message' in login_data:
             raise AuthError, _('Unable to login to server: %(message)s') \
-                    % loginData
+                    % login_data
 
-        self._sessionCookie = Cookie.SimpleCookie()
+        self._session_cookie = Cookie.SimpleCookie()
         try:
-            self._sessionCookie.load(loginPage.headers['set-cookie'])
+            self._session_cookie.load(login_page.headers['set-cookie'])
         except KeyError:
-            self._sessionCookie = None
+            self._session_cookie = None
             raise AuthError, _('Unable to login to the server.  Server did' \
                     ' not send back a cookie')
         self._save_session()
 
-        return self._sessionCookie
+        return self._session_cookie
     session = property(_authenticate)
 
     def _save_session(self):
@@ -161,22 +160,22 @@
         '''
         save = {}
         if path.isfile(SESSION_FILE):
-            sessionFile = file(SESSION_FILE, 'r')
+            session_file = file(SESSION_FILE, 'r')
             # pylint: disable-msg=W0702
             try:
-                save = pickle.load(sessionFile)
+                save = pickle.load(session_file)
             except: # pylint: disable-msg=W0704
                 # If there isn't a session file yet, there's no problem
                 pass
             # pylint: enable-msg=W0702
-            sessionFile.close()
-        save[self.username] = self._sessionCookie
+            session_file.close()
+        save[self.username] = self._session_cookie
         try:
-            sessionFile = file(SESSION_FILE, 'w')
+            session_file = file(SESSION_FILE, 'w')
             os.chmod(SESSION_FILE, stat.S_IRUSR | stat.S_IWUSR)
-            pickle.dump(save, sessionFile)
-            sessionFile.close()
-        except Exception, e:
+            pickle.dump(save, session_file)
+            session_file.close()
+        except Exception, e: # pylint: disable-msg=W0703
             # If we can't save the file, issue a warning but go on.  The
             # session just keeps you from having to type your password over
             # and over.
@@ -188,18 +187,18 @@
             Load a stored session cookie.
         '''
         if path.isfile(SESSION_FILE):
-            sessionFile = file(SESSION_FILE, 'r')
+            session_file = file(SESSION_FILE, 'r')
             try:
-                savedSession = pickle.load(sessionFile)
-                self._sessionCookie = savedSession[self.username]
+                saved_session = pickle.load(session_file)
+                self._session_cookie = saved_session[self.username]
                 log.debug(_('Loaded session %(cookie)s') % \
-                        {'cookie': self._sessionCookie})
+                        {'cookie': self._session_cookie})
             except EOFError:
                 log.warning(_('Unable to load session from %(file)s') % \
                         {'file': SESSION_FILE})
             except KeyError:
                 log.debug(_('Session is for a different user'))
-            sessionFile.close()
+            session_file.close()
 
     def logout(self):
         '''
@@ -212,21 +211,21 @@
             # our authentication tokens here.
             pass
       
-    def send_request(self, method, auth=False, reqParams=None):
+    def send_request(self, method, auth=False, req_params=None):
         '''Make an HTTP request to a server method.
 
-        The given method is called with any parameters set in reqParams.  If
+        The given method is called with any parameters set in req_params.  If
         auth is True, then the request is made with an authenticated session
         cookie.
 
         Arguments:
         :method: Method to call on the server.  It's a url fragment that comes
-            after the baseURL set in __init__().
+            after the base_url set in __init__().
         :auth: If True perform auth to the server, else do not.
-        :reqParams: Extra parameters to send to the server.
+        :req_params: Extra parameters to send to the server.
         '''
         method = method.lstrip('/')
-        url = urljoin(self.baseURL, method + '?tg_format=json')
+        url = urljoin(self.base_url, method + '?tg_format=json')
 
         response = None # the JSON that we get back from the server
         data = None     # decoded JSON via simplejson.load()
@@ -235,15 +234,15 @@
         req = urllib2.Request(url)
         req.add_header('User-agent', self.useragent)
         req.add_header('Accept', 'text/javascript')
-        if reqParams:
-            req.add_data(urllib.urlencode(reqParams))
+        if req_params:
+            req.add_data(urllib.urlencode(req_params))
 
         if auth:
             req.add_header('Cookie', self.session.output(attrs=[],
                 header='').strip())
-        elif self._sessionCookie:
+        elif self._session_cookie:
             # If the cookie exists, send it so that visit tracking works.
-            req.add_header('Cookie', self._sessionCookie.output(attrs=[],
+            req.add_header('Cookie', self._session_cookie.output(attrs=[],
                 header='').strip())
         try:
             response = urllib2.urlopen(req)
@@ -252,7 +251,7 @@
                 if (inspect.currentframe().f_back.f_code !=
                         inspect.currentframe().f_code):
                     self._authenticate(force=True)
-                    return self.send_request(method, auth, reqParams)
+                    return self.send_request(method, auth, req_params)
                 else:
                     # We actually shouldn't ever reach here.  Unless something
                     # goes drastically wrong _authenticate should raise an
@@ -265,14 +264,14 @@
 
         # In case the server returned a new session cookie to us
         try:
-            self._sessionCookie.load(response.headers['set-cookie'])
+            self._session_cookie.load(response.headers['set-cookie'])
         except (KeyError, AttributeError): # pylint: disable-msg=W0704
             # It's okay if the server didn't send a new cookie
             pass
 
-        jsonString = response.read()
+        json_string = response.read()
         try:
-            data = simplejson.loads(jsonString)
+            data = simplejson.loads(json_string)
         except ValueError, e:
             # The response wasn't JSON data
             raise ServerError, str(e)
@@ -284,7 +283,7 @@
             if (inspect.currentframe().f_back.f_code !=
                     inspect.currentframe().f_code):
                 self._authenticate(force=True)
-                data = self.send_request(method, auth, reqParams)
+                data = self.send_request(method, auth, req_params)
             else:
                 # We actually shouldn't ever reach here.  Unless something goes
                 # drastically wrong _authenticate should raise an AuthError

=== modified file 'fedora/tg/identity/__init__.py'
--- fedora/tg/identity/__init__.py	2007-01-18 23:49:07 +0000
+++ fedora/tg/identity/__init__.py	2008-06-03 23:55:57 +0000
@@ -0,0 +1,1 @@
+'''TurboGears identity modules that work with Fedora.'''

=== modified file 'fedora/tg/identity/jsonfasprovider.py'
--- fedora/tg/identity/jsonfasprovider.py	2008-06-02 17:52:45 +0000
+++ fedora/tg/identity/jsonfasprovider.py	2008-06-04 00:39:34 +0000
@@ -46,7 +46,9 @@
     from sets import ImmutableSet as frozenset  # pylint: disable-msg=W0622
 
 class DictContainer(dict):
+    '''Dictionary that also works from attribute lookups.'''
     def __init__(self, basedict):
+        super(DictContainer, self).__init__()
         for key in basedict:
             if type(basedict[key]) == dict:
                 self[key] = DictContainer(basedict[key])
@@ -64,12 +66,12 @@
 class JsonFasIdentity(BaseClient):
     '''Associate an identity with a person in the auth system.
     '''
-    cookieName = config.get('visit.cookie.name', 'tg-visit')
-    fasURL = config.get('fas.url', 'https://admin.fedoraproject.org/accounts/')
+    cookie_name = config.get('visit.cookie.name', 'tg-visit')
+    fas_url = config.get('fas.url', 'https://admin.fedoraproject.org/accounts/')
 
     def __init__(self, visit_key, user=None, username=None, password=None,
             debug=False):
-        super(JsonFasIdentity, self).__init__(self.fasURL, debug=debug)
+        super(JsonFasIdentity, self).__init__(self.fas_url, debug=debug)
         if user:
             self._user = user
             self._groups = frozenset(
@@ -84,9 +86,9 @@
 
         # Set the cookie to the user's tg_visit key before requesting
         # authentication.  That way we link the two together.
-        self._sessionCookie = Cookie.SimpleCookie()
-        self._sessionCookie[self.cookieName] = visit_key
-        response.simple_cookie[self.cookieName] = visit_key
+        self._session_cookie = Cookie.SimpleCookie()
+        self._session_cookie[self.cookie_name] = visit_key
+        response.simple_cookie[self.cookie_name] = visit_key
 
         self.username = username
         self.password = password
@@ -97,26 +99,29 @@
         '''Override BaseClient so we can keep visit_key in sync.
         '''
         super(JsonFasIdentity, self)._authenticate(force)
-        if self._sessionCookie[self.cookieName].value != self.visit_key:
+        if self._session_cookie[self.cookie_name].value != self.visit_key:
             # When the visit_key changes (because the old key had expired or
             # been deleted from the db) change the visit_key in our variables
             # and the session cookie to be sent back to the client.
-            self.visit_key = self._sessionCookie[self.cookieName].value
-            response.simple_cookie[self.cookieName] = self.visit_key
-        return self._sessionCookie
+            self.visit_key = self._session_cookie[self.cookie_name].value
+            response.simple_cookie[self.cookie_name] = self.visit_key
+        return self._session_cookie
     session = property(_authenticate)
 
     def _get_user(self):
         '''Retrieve information about the user from cache or network.'''
+        # pylint: disable-msg=W0704
         try:
             return self._user
         except AttributeError:
             # User hasn't already been set
             pass
+        # pylint: enable-msg=W0704
         # Attempt to load the user. After this code executes, there *WILL* be
         # a _user attribute, even if the value is None.
         # Query the account system URL for our given user's sessionCookie
         # FAS returns user and group listing
+        # pylint: disable-msg=W0702
         try:
             data = self.send_request('user/view', auth=True)
         except:
@@ -124,6 +129,7 @@
             # framework doesn't know what to do otherwise.
             self._user = None
             return None
+        # pylint: enable-msg=W0702
         if not data['person']:
             self._user = None
             return None
@@ -135,22 +141,26 @@
     user = property(_get_user)
 
     def _get_user_name(self):
+        '''Return the username for the user.'''
         if not self.user:
             return None
         return self.user['username']
     user_name = property(_get_user_name)
 
     def _get_anonymous(self):
+        '''Return True if there's no user logged in.'''
         return not self.user
     anonymous = property(_get_anonymous)
 
     def _get_display_name(self):
+        '''Return the user's display name.'''
         if not self.user:
             return None
         return self.user['human_name']
     display_name = property(_get_display_name)
 
     def _get_groups(self):
+        '''Return the groups that a user is a member of.'''
         try:
             return self._groups
         except AttributeError:

=== modified file 'fedora/tg/json.py'
--- fedora/tg/json.py	2008-06-01 20:43:05 +0000
+++ fedora/tg/json.py	2008-06-02 18:30:13 +0000
@@ -53,30 +53,30 @@
 
         This method takes an SA mapped class and turns the "normal" python
         attributes into json.  The properties (from properties in the mapper)
-        are also included if they have an entry in jsonProps.  You make
-        use of this by setting jsonProps in the controller.
+        are also included if they have an entry in json_props.  You make
+        use of this by setting json_props in the controller.
 
         Example controller::
           john = model.Person.get_by(name='John')
           # Person has a property, addresses, linking it to an Address class.
           # Address has a property, phone_nums, linking it to a Phone class.
-          john.jsonProps = {'Person': ['addresses'],
+          john.json_props = {'Person': ['addresses'],
                   'Address': ['phone_nums']}
           return dict(person=john)
 
-        jsonProps is a dict that maps class names to lists of properties you
+        json_props is a dict that maps class names to lists of properties you
         want to output.  This allows you to selectively pick properties you
         are interested in for one class but not another.  You are responsible
         for avoiding loops.  ie: *don't* do this::
-            john.jsonProps = {'Person': ['addresses'], 'Address': ['people']}
+            john.json_props = {'Person': ['addresses'], 'Address': ['people']}
         '''
         props = {}
         # pylint: disable-msg=E1101
-        if hasattr(self, 'jsonProps') \
-                and self.jsonProps.has_key(self.__class__.__name__):
-            propList = self.jsonProps[self.__class__.__name__]
+        if hasattr(self, 'json_props') \
+                and self.json_props.has_key(self.__class__.__name__):
+            prop_list = self.json_props[self.__class__.__name__]
         else:
-            propList = {}
+            prop_list = {}
         # pylint: enable-msg=E1101
        
         # Load all the columns from the table
@@ -85,14 +85,14 @@
                 props[column.key] = getattr(self, column.key)
 
         # Load things that are explicitly listed
-        for field in propList:
+        for field in prop_list:
             props[field] = getattr(self, field)
             try:
                 # pylint: disable-msg=E1101
-                props[field].jsonProps = self.jsonProps
+                props[field].json_props = self.json_props
             except AttributeError: # pylint: disable-msg=W0704
                 # Certain types of objects are terminal and won't allow setting
-                # jsonProps
+                # json_props
                 pass
 
             # Note: Because of the architecture of simplejson and turbojson,
@@ -109,13 +109,13 @@
 def jsonify_sa_select_results(obj):
     '''Transform selectresults into lists.
     
-    The one special thing is that we bind the special jsonProps into each
-    descendent.  This allows us to specify a jsonProps on the toplevel
+    The one special thing is that we bind the special json_props into each
+    descendent.  This allows us to specify a json_props on the toplevel
     query result and it will pass to all of its children.
     '''
-    if 'jsonProps' in obj.__dict__:
+    if 'json_props' in obj.__dict__:
         for element in obj:
-            element.jsonProps = obj.jsonProps
+            element.json_props = obj.json_props
     return list(obj)
 
 # Note: due to the way simplejson works, InstrumentedList has to be taken care
@@ -128,13 +128,13 @@
 def jsonify_salist(obj):
     '''Transform SQLAlchemy InstrumentedLists into json.
     
-    The one special thing is that we bind the special jsonProps into each
-    descendent.  This allows us to specify a jsonProps on the toplevel
+    The one special thing is that we bind the special json_props into each
+    descendent.  This allows us to specify a json_props on the toplevel
     query result and it will pass to all of its children.
     '''
-    if 'jsonProps' in obj.__dict__:
+    if 'json_props' in obj.__dict__:
         for element in obj:
-            element.jsonProps = obj.jsonProps
+            element.json_props = obj.json_props
     return [jsonify(element) for element in  obj]
 
 @jsonify.when('''(
@@ -143,12 +143,12 @@
 def jsonify_saresult(obj):
     '''Transform SQLAlchemy ResultProxy into json.
     
-    The one special thing is that we bind the special jsonProps into each
-    descendent.  This allows us to specify a jsonProps on the toplevel
+    The one special thing is that we bind the special json_props into each
+    descendent.  This allows us to specify a json_props on the toplevel
     query result and it will pass to all of its children.
     '''
-    if 'jsonProps' in obj.__dict__:
+    if 'json_props' in obj.__dict__:
         for element in obj:
-            element.jsonProps = obj.jsonProps
+            element.json_props = obj.json_props
     return [list(row) for row in obj]
 

=== modified file 'fedora/tg/visit/__init__.py'
--- fedora/tg/visit/__init__.py	2008-02-16 05:19:06 +0000
+++ fedora/tg/visit/__init__.py	2008-06-04 00:01:26 +0000
@@ -0,0 +1,1 @@
+'''TurboGears visit manager to save visit in the Fedora Account System.'''

=== modified file 'fedora/tg/visit/jsonfasvisit.py'
--- fedora/tg/visit/jsonfasvisit.py	2008-06-01 20:38:48 +0000
+++ fedora/tg/visit/jsonfasvisit.py	2008-06-04 00:26:12 +0000
@@ -22,8 +22,8 @@
     We don't need to worry about threading and other concerns because our proxy
     doesn't cause any asynchronous calls.
     '''
-    fasURL = config.get('fas.url', 'https://admin.fedoraproject.org/admin/fas')
-    cookieName = config.get('visit.cookie.name', 'tg-visit')
+    fas_url = config.get('fas.url', 'https://admin.fedoraproject.org/admin/fas')
+    cookie_name = config.get('visit.cookie.name', 'tg-visit')
 
     def __init__(self, timeout, debug=None):
         self.debug = debug or False
@@ -43,11 +43,11 @@
         '''
         # Hit any URL in fas2 with the visit_key set.  That will call the
         # new_visit method in fas2
-        fas = BaseClient(self.fasURL, self.debug)
-        fas._sessionCookie = Cookie.SimpleCookie()
-        fas._sessionCookie[self.cookieName] = visit_key
+        fas = BaseClient(self.fas_url, self.debug)
+        fas._session_cookie = Cookie.SimpleCookie()
+        fas._session_cookie[self.cookie_name] = visit_key
         fas.send_request('', auth=True)
-        return Visit(fas._sessionCookie[self.cookieName].value, True)
+        return Visit(fas._session_cookie[self.cookie_name].value, True)
 
     def visit_for_key(self, visit_key):
         '''
@@ -56,29 +56,29 @@
         '''
         # Hit any URL in fas2 with the visit_key set.  That will call the
         # new_visit method in fas2
-        fas = BaseClient(self.fasURL, self.debug)
-        fas._sessionCookie = Cookie.SimpleCookie()
-        fas._sessionCookie[self.cookieName] = visit_key
+        fas = BaseClient(self.fas_url, self.debug)
+        fas._session_cookie = Cookie.SimpleCookie()
+        fas._session_cookie[self.cookie_name] = visit_key
         fas.send_request('', auth=True)
         # Knowing what happens in turbogears/visit/api.py when this is called,
         # we can shortcircuit this step and avoid a round trip to the FAS
         # server.
-        # if visit_key != self._sessionCookie[self.cookieName].value:
+        # if visit_key != self._session_cookie[self.cookie_name].value:
         #     # visit has expired
         #     return None
         # # Hitting FAS has already updated the visit.
         # return Visit(visit_key, False)
-        if visit_key != fas._sessionCookie[self.cookieName].value:
-            return Visit(fas._sessionCookie[self.cookieName].value, True)
+        if visit_key != fas._session_cookie[self.cookie_name].value:
+            return Visit(fas._session_cookie[self.cookie_name].value, True)
         else:
             return Visit(visit_key, False)
 
     def update_queued_visits(self, queue):
         '''Update the visit information on the server'''
-        fas = BaseClient(self.fasURL, self.debug)
+        fas = BaseClient(self.fas_url, self.debug)
         for visit_key in queue:
             log.info(_('updating visit (%s)'), visit_key)
-            fas._sessionCookie = Cookie.SimpleCookie()
-            fas._sessionCookie[self.cookieName] = visit_key
+            fas._session_cookie = Cookie.SimpleCookie()
+            fas._session_cookie[self.cookie_name] = visit_key
             fas.send_request('', auth=True)
             fas.send_request()

=== modified file 'fedora/tg/widgets.py'
--- fedora/tg/widgets.py	2008-06-01 20:39:12 +0000
+++ fedora/tg/widgets.py	2008-06-04 00:13:26 +0000
@@ -33,17 +33,17 @@
     '''
     template = """
        <table xmlns:py="http://purl.org/kid/ns#";
-         class="widget FedoraPeopleWidget" py:attrs="{'id': widgetId}">
+         class="widget FedoraPeopleWidget" py:attrs="{'id': widget_id}">
           <tr py:for="entry in entries[:5]">
             <td><img src="${entry['image']}" height="32" width="32"/></td>
             <td><a href="${entry['link']}">${entry['title']}</a></td>
           </tr>
         </table>
     """
-    params = ["widgetId", "entries"]
+    params = ["widget_id", "entries"]
 
-    def __init__(self, widgetId=None):
-        self.widgetId = widgetId
+    def __init__(self, widget_id=None):
+        self.widget_id = widget_id
         self.entries = []
         regex = re.compile('<img src="(.*)" alt="" />')
         feed = feedparser.parse('http://planet.fedoraproject.org/rss20.xml')
@@ -55,34 +55,35 @@
             })
 
     def __json__(self):
-        return {'id': self.widgetId, 'entries': self.entries}
+        return {'id': self.widget_id, 'entries': self.entries}
 
 class FedoraMaintainerWidget(Widget):
     '''Widget to show the packages a maintainer owns.
     '''
     template = """
        <table xmlns:py="http://purl.org/kid/ns#";
-         class="widget FedoraMaintainerWidget" py:attrs="{'id': widgetId}">
+         class="widget FedoraMaintainerWidget" py:attrs="{'id': widget_id}">
           <tr py:for="pkg in packages[:5]">
             <td><a href="https://admin.fedoraproject.org/pkgdb/packages/name/${pkg['name']}">${pkg['name']}</a></td>
           </tr>
        </table>
     """
-    params = ["widgetId", "packages"]
+    params = ["widget_id", "packages"]
 
-    def __init__(self, username, widgetId=None):
-        self.widgetId = widgetId
+    def __init__(self, username, widget_id=None):
+        self.widget_id = widget_id
         page = urllib2.urlopen('https://admin.fedoraproject.org/pkgdb/' \
                 'users/packages/%s/?tg_format=json' % username)
         self.packages = simplejson.load(page)['pkgs']
 
     def __json__(self):
-        return {'id': self.widgetId, 'packages': self.packages}
+        return {'id': self.widget_id, 'packages': self.packages}
 
 class BugzillaWidget(Widget):
+    '''Widget to show the stream of bugs submitted against a package.'''
     template = """
        <table xmlns:py="http://purl.org/kid/ns#"; class="widget BugzillaWidget"
-          py:attrs="{'id': widgetId}">
+          py:attrs="{'id': widget_id}">
           <tr py:for="bug in bugs">
             <td>
               <a href="${bug.url}">${bug.bug_id}</a> ${bug.short_short_desc}
@@ -90,16 +91,16 @@
           </tr>
        </table>
     """
-    params = ["widgetId", "bugs"]
+    params = ["widget_id", "bugs"]
 
-    def __init__(self, email, widgetId=None):
-        self.widgetId = widgetId
-        bz = Bugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi')
-        self.bugs = bz.query({
+    def __init__(self, email, widget_id=None):
+        self.widget_id = widget_id
+        bugzilla = Bugzilla(url='https://bugzilla.redhat.com/xmlrpc.cgi')
+        self.bugs = bugzilla.query({
             'product'           : 'Fedora',
             'email1'            : email,
             'emailassigned_to1' : True
         })[:5]
 
     def __json__(self):
-        return {'id': self.widgetId, 'bugs': self.bugs}
+        return {'id': self.widget_id, 'bugs': self.bugs}

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Fedora-infrastructure-list mailing list
Fedora-infrastructure-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-infrastructure-list

[Index of Archives]     [Fedora Development]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]

  Powered by Linux