[Checkins] SVN: grokui.admin/trunk/s zope.site is back as a dependency, as this was needed by the server module.

Souheil CHELFOUH souheil at chelfouh.com
Mon Feb 22 13:30:36 EST 2010


Log message for revision 109316:
  zope.site is back as a dependency, as this was needed by the server module.
  Added all the missing imports and cleaned the code to be pep8 compliant.
  

Changed:
  U   grokui.admin/trunk/setup.py
  U   grokui.admin/trunk/src/grokui/admin/applications.py
  U   grokui.admin/trunk/src/grokui/admin/interfaces.py
  U   grokui.admin/trunk/src/grokui/admin/representation.py
  U   grokui.admin/trunk/src/grokui/admin/security.py
  U   grokui.admin/trunk/src/grokui/admin/server.py
  U   grokui.admin/trunk/src/grokui/admin/utilities.py
  U   grokui.admin/trunk/src/grokui/admin/views.py

-=-
Modified: grokui.admin/trunk/setup.py
===================================================================
--- grokui.admin/trunk/setup.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/setup.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -57,6 +57,7 @@
           'zope.login',
           'zope.schema',
           'zope.size',
+          'zope.site',
           'zope.traversing',
           ],
       tests_require = tests_require,

Modified: grokui.admin/trunk/src/grokui/admin/applications.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/applications.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/applications.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -14,7 +14,7 @@
 
 class InstalledApplication(object):
     grok.implements(representation.IInstalledApplication)
-   
+
     def __init__(self, obj, request):
         self.__name__ = obj.__name__
         self.url = absoluteURL(obj, request)
@@ -41,13 +41,13 @@
 
 class InstallableApplication(object):
     grok.implements(representation.IInstallableApplication)
-    
+
     def __init__(self, klass):
         self.__name__ = klass.__name__
         self.classname = ".".join((klass.__module__, klass.__name__))
         self.description = unicode(getattr(klass, '__doc__', u'') or u'')
 
-    
+
 class ApplicationInfo(grok.View):
     grok.name('info')
     grok.context(representation.IApplicationRepresentation)

Modified: grokui.admin/trunk/src/grokui/admin/interfaces.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/interfaces.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/interfaces.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -16,6 +16,7 @@
 from zope.interface import Interface
 from zope.schema import TextLine, Bool
 
+
 class ISecurityNotifier(Interface):
     """A notifier the looks up security warnings somewhere.
     """
@@ -24,16 +25,14 @@
         title=u"Lookup URL",
         description=u"URL to use when doing lookups",
         required=True,
-        default=u'http://grok.zope.org/releasinfo/'
-        )
-        
+        default=u'http://grok.zope.org/releasinfo/')
+
     enabled = Bool(
         title=u"Enabled",
         description=u"Notifier instance is enabled or disabled",
         required=True,
-        default=False
-        )
-    
+        default=False)
+
     def enable():
         """Enable security notifications.
         """

Modified: grokui.admin/trunk/src/grokui/admin/representation.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/representation.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/representation.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -8,20 +8,20 @@
 
 
 class IApplicationRepresentation(Interface):
-    """Defines an Grok application 
+    """Defines an Grok application
     """
     __name__ = schema.TextLine(
-        title = u"Name",
-        required = True)
-    
+        title=u"Name",
+        required=True)
+
     classname = PythonIdentifier(
-        title = u"Dotted name of the Application class",
-        required = True)
-    
+        title=u"Dotted name of the Application class",
+        required=True)
+
     description = schema.Text(
-        title = u"Description of the Application",
-        default = u"",
-        required = False)
+        title=u"Description of the Application",
+        default=u"",
+        required=False)
 
 
 class IInstallableApplication(IApplicationRepresentation):
@@ -33,8 +33,8 @@
     """Defines an application that is installed in our system.
     """
     url = schema.URI(
-        title = u"Absolute URL of the application",
-        required = True)
+        title=u"Absolute URL of the application",
+        required=True)
 
 
 class IApplicationInformation(IContentProvider):

Modified: grokui.admin/trunk/src/grokui/admin/security.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/security.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/security.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -52,7 +52,7 @@
 
     VERSION = 1 # for possibly updates/downgrades
     DEFAULT_URL = 'http://grok.zope.org/releaseinfo/'
-    
+
     lookup_url = DEFAULT_URL
     last_lookup = None   # When did we do the last lookup?
     lookup_timeout = 2   # Number of seconds to wait
@@ -62,7 +62,7 @@
 
     _message = u''
     _warningstate = False
-    
+
     def enable(self):
         """Enable security notifications.
         """
@@ -86,7 +86,7 @@
     def isWarning(self):
         self.updateMessage()
         return self._warningstate
-    
+
     def updateMessage(self):
         """Update the security message.
         """
@@ -97,7 +97,7 @@
                 return
         self.fetchMessage()
         return
-    
+
     def fetchMessage(self):
         """Possibly fetch security notfications from grok.zope.org.
         """
@@ -135,7 +135,7 @@
         self.lookup_url = url
         self.last_lookup = None
         return
-    
+
     def display(self):
         """Display the message.
 

Modified: grokui.admin/trunk/src/grokui/admin/server.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/server.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/server.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -12,6 +12,7 @@
 from ZODB.FileStorage.FileStorage import FileStorageError
 
 from zope.size import byteDisplay
+from zope.site.interfaces import IRootFolder
 from zope.applicationcontrol.interfaces import IServerControl, IRuntimeInfo
 from zope.applicationcontrol.applicationcontrol import applicationController
 from zope.component import getUtility, queryUtility, getUtilitiesFor
@@ -38,7 +39,7 @@
         "ProcessId",
         "DeveloperMode",
         )
-    
+
     _unavailable = _("Unavailable")
 
     @property
@@ -51,7 +52,6 @@
 
     def root_url(self, name=None):
         obj = self.context
-        result = ""
         while obj is not None:
             if IRootFolder.providedBy(obj):
                 return self.url(obj, name)
@@ -63,7 +63,7 @@
         """Get the URL to look up for security warnings.
         """
         return self.security_notifier.lookup_url
-    
+
     @property
     def security_notifier(self):
         """Get a local security notifier.
@@ -74,7 +74,7 @@
         site = grok.getSite()
         site_manager = site.getSiteManager()
         return site_manager.queryUtility(ISecurityNotifier, default=None)
-    
+
     @property
     def secnotes_enabled(self):
         if self.security_notifier is None:
@@ -86,7 +86,7 @@
         if self.security_notifier is None:
             return u'Security notifier is not installed.'
         return self.security_notifier.getNotification()
-    
+
     @property
     def server_control(self):
         return queryUtility(IServerControl)
@@ -100,7 +100,7 @@
             formatted["Uptime"] = self._unavailable
         else:
             formatted = self._getInfo(ri)
-            
+
         return formatted
 
     def _getInfo(self, ri):
@@ -122,12 +122,11 @@
         days, hours = divmod(hours, 24)
 
         return _('${days} day(s) ${hours}:${minutes}:${seconds}',
-                 mapping = {'days': '%d' % days,
-                            'hours': '%02d' % hours,
-                            'minutes': '%02d' % minutes,
-                            'seconds': '%02d' % seconds})
+                 mapping={'days': '%d' % days,
+                          'hours': '%02d' % hours,
+                          'minutes': '%02d' % minutes,
+                          'seconds': '%02d' % seconds})
 
-
     @property
     def current_message(self):
         source = getUtility(
@@ -146,7 +145,7 @@
                 utility = site_manager['grokadmin_security']
                 site_manager.registerUtility(
                     utility, ISecurityNotifier, name=u'')
-                
+
         if setsecnotesource is not None:
             self.security_notifier.setLookupURL(secnotesource)
         if setsecnotes is not None:
@@ -157,7 +156,7 @@
         if self.secnotes_enabled is False:
             return
         return
-        
+
     def update(self, time=None, restart=None, shutdown=None,
                setsecnotes=None, secnotesource=None, setsecnotesource=None,
                admin_message=None, submitted=False, dbName="", pack=None,
@@ -171,7 +170,7 @@
         self.updateSecurityNotifier(setsecnotes, setsecnotesource,
                                     secnotesource)
 
-        
+
         if not submitted:
             return
 
@@ -203,16 +202,17 @@
     def databases(self):
         res = []
         for name, db in getUtilitiesFor(IDatabase):
-            d = dict(dbName = db.getName(),
-                     utilName = str(name),
-                     size = self._getSize(db),
-                     )
+            d = dict(
+                dbName=db.getName(),
+                utilName=str(name),
+                size=self._getSize(db))
             res.append(d)
         return res
-            
+
     def _getSize(self, db):
-        """Get the database size in a human readable format."""
-        size = db.getSize()        
+        """Get the database size in a human readable format.
+        """
+        size = db.getSize()
         if not isinstance(size, (int, long, float)):
             return str(size)
         return byteDisplay(size)
@@ -221,7 +221,7 @@
         try:
             days = int(days)
         except ValueError:
-            flash('Error: Invalid Number')
+            self.flash('Error: Invalid Number')
             return
         db = getUtility(IDatabase, name=dbName)
         print "DB: ", db, days
@@ -229,6 +229,6 @@
         return
         try:
             db.pack(days=days)
-            flash('ZODB `%s` successfully packed.' % (dbName))
+            self.flash('ZODB `%s` successfully packed.' % (dbName))
         except FileStorageError, err:
-            flash('ERROR packing ZODB `%s`: %s' % (dbName, err))
+            self.flash('ERROR packing ZODB `%s`: %s' % (dbName, err))

Modified: grokui.admin/trunk/src/grokui/admin/utilities.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/utilities.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/utilities.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -12,7 +12,7 @@
     to enable use of ``grokui.admin`` with Grok versions < 0.13.
     """
     if data:
-        for k,v in data.items():
+        for k, v in data.items():
             if isinstance(v, unicode):
                 data[k] = v.encode('utf-8')
             if isinstance(v, (list, set, tuple)):
@@ -35,6 +35,7 @@
     """A customised HTTPConnection allowing a per-connection
     timeout, specified at construction.
     """
+
     def __init__(self, host, port=None, strict=None, timeout=None):
         httplib.HTTPConnection.__init__(self, host, port,
                 strict)
@@ -67,15 +68,17 @@
     """A customised HTTPHandler which times out connection
     after the duration specified at construction.
     """
+
     def __init__(self, timeout=None):
         urllib2.HTTPHandler.__init__(self)
         self.timeout = timeout
 
     def http_open(self, req):
-        """Override http_open."""
+        """Override http_open.
+        """
 
         def makeConnection(host, port=None, strict=None):
-            return TimeoutableHTTPConnection(host, port, strict,
-                    timeout = self.timeout)
+            return TimeoutableHTTPConnection(
+                host, port, strict, timeout=self.timeout)
 
         return self.do_open(makeConnection, req)

Modified: grokui.admin/trunk/src/grokui/admin/views.py
===================================================================
--- grokui.admin/trunk/src/grokui/admin/views.py	2010-02-22 18:10:23 UTC (rev 109315)
+++ grokui.admin/trunk/src/grokui/admin/views.py	2010-02-22 18:30:36 UTC (rev 109316)
@@ -25,7 +25,7 @@
     """
     grok.name('admin')
     grok.require('grok.ManageApplications')
-    
+
     def render(self):
         return u'go to @@version or @@secnotes'
 
@@ -41,7 +41,7 @@
     grok.name('version')
     grok.context(GrokAdminInfoView)
     grok.require('grok.ManageApplications')
-    
+
     def render(self, pkg='grok'):
         return u'%s %s' % (pkg, getVersion(pkg))
 
@@ -54,7 +54,7 @@
     grok.name('secnote')
     grok.context(GrokAdminInfoView)
     grok.require('grok.ManageApplications')
-    
+
     def render(self):
         notifier = queryUtility(ISecurityNotifier, default=None)
         return (notifier is not None and notifier.getNotification()
@@ -68,8 +68,9 @@
 
     def update(self, inspectapp=None, application=None):
         if inspectapp is not None:
-            self.redirect(self.url("docgrok") + "/%s/index"%(
-                    application.replace('.','/'),))
+            self.redirect(
+                "%s/%s/index" % (
+                    self.url("docgrok"), application.replace('.', '/')))
         return
 
     def render(self, application, name, inspectapp=None):
@@ -109,7 +110,6 @@
             except AttributeError:
                 # Object is broken.. Try it the hard way...
                 # TODO: Try to repair before deleting.
-                obj = self.context.root[name]
                 if not hasattr(self.context.root, 'data'):
                     msg = (
                         u'%sCould not delete application `%s`: no '
@@ -153,7 +153,6 @@
     grok.require('grok.ManageApplications')
 
     def update(self, cancel=None, items=None, new_names=None):
-        msg = u''
 
         if cancel is not None or not items:
             return self.redirect(self.url(self.context, 'applications'))



More information about the checkins mailing list