[Checkins] SVN: grok/trunk/src/grok/admin/objectinfo.py Remove trash.

Uli Fouquet uli at gnufix.de
Thu Sep 20 17:10:28 EDT 2007


Log message for revision 79772:
  Remove trash.

Changed:
  U   grok/trunk/src/grok/admin/objectinfo.py

-=-
Modified: grok/trunk/src/grok/admin/objectinfo.py
===================================================================
--- grok/trunk/src/grok/admin/objectinfo.py	2007-09-20 20:36:15 UTC (rev 79771)
+++ grok/trunk/src/grok/admin/objectinfo.py	2007-09-20 21:10:27 UTC (rev 79772)
@@ -567,246 +567,3 @@
                or getattr(self.obj, 'id', None)
                or getattr(self.obj, '_o_id', None))
 
-
-from zope.traversing.interfaces import ITraversable
-from zope.app.folder.interfaces import IRootFolder
-from zope.location import LocationProxy
-class AnnotationsTraverser(grok.Traverser):
-    """If first URL element is '++anno++', handle over to
-    ObjectBrowser.
-
-    This traverser binds to the RootFolder, which means, it is only
-    asked, when the publisher looks for elements in the Zope root (or
-    another IRootFolder). The further traversing is done by the Docs'
-    own traverser in it's model. See method `traverse()` in DocGrok.
-    """
-    grok.context(Interface)
-    #grok.name('anno')
-    #grok.provides(ITraversable)
-
-    def traverse(self,path):
-        namespace = 'anno'
-        if path.startswith(namespace):
-            name = path[len(namespace):]
-            naked = removeSecurityProxy(self.context)
-            annotations = IAnnotations(naked)
-            obj = ObjectInfo("Hello")
-            if not IPhysicallyLocatable(obj, False):
-                obj = LocationProxy(
-                    obj, self.context, 'anno' + name)
-            return obj
-        return
-
-    def render(self):
-        pass
-
-##
-## This comes from Dieter Maurer:
-##
-
-def determineClass(o):
-  return hasattr(o, '__class__') and o.__class__ or type(o)
-
-class Recorder(object):
-  def __init__(self): self._account = {}
-  def __call__(self, o):
-    a = self._account
-    class_ = determineClass(o)
-    if class_ in a: a[class_] += 1
-    else: a[class_] = 1
-  def account(self): return self._account
-
-def sortRecords(recorder):
-  return sorted(recorder.account().items(), key=lambda r: r[1], reverse=True)
-
-def fix((ty, no)):
-  '''some types apparently have a broken 'str'. Fix this.'''
-  try: tyn = str(ty)
-  except TypeError:
-    try: tyn = 'BROKEN-STR: %r' % ty
-    except TypeError: tyn = 'BROKEN-STR-AND-REPR'
-  return tyn, no
-
-def analyseObjects(limit=100):
-  '''analyses live objects and garbage.
-
-  The result is a pair with information for live and garbage objects, respectively.
-  The information is a dict with keys 'count' and 'sorted'.
-  'count' is the total number of objects, 'sorted' a list with pairs
-  'type' and 'instanceCount', inverse sorted by 'instanceCount'.
-  '''
-  result = []
-  import gc
-  for objs in gc.get_objects(), gc.garbage:
-    r = Recorder()
-    for o in objs: r(o)
-    result.append({
-      'count':len(objs),
-      'sorted':map(fix, sortRecords(r)[:limit]),
-      })
-  return result
-
-
-
-
-
-
-
-
-
-
-
-
-class ObjectInfo_obsolete(object):
-    """A wrapper to provide object specific information.
-
-    This is the base wrapper.
-    
-    See inspect.txt to learn more about this kind of thing.
-    """
-
-    def __init__(self, obj):
-        self.obj = obj
-
-    def getName(self):
-        """Try to determine the name of an object.
-        """
-        for key in ['__name__', 'id', 'title', '_o_id']:
-            name = getattr(self.obj, key, None)
-            if name is not None:
-                break
-        return name
-
-    def getDoc(self):
-        """Fetch any doc strings from the wrapped object.
-        """
-        if hasattr(self.obj, '__class__'):
-            return getattr(self.obj.__class__, '__doc__', None)
-        return
-
-    def getType(self):
-        """Get the wrapped objects' type as a string in dotted path
-        notation.
-        """
-        return type(self.obj)
-
-    def getParent(self):
-        """Get the parent of the wrapped object.
-
-        This might result in a `TypeError` if the wrapped object is
-        not locatable in sense of ILocation, i.e. if it doesn't
-        provide ``__parent__`` attribute.
-        """
-        return getParent(self.obj)
-
-    def getChildren(self):
-        """Returns a list of children objects.
-        """
-        return dir(self.obj)
-
-    def getRoot(self):
-        """Get the root obj of the wrapped object.
-        """
-        try:
-            return getRoot(self.obj)
-        except TypeError:
-            tmp = self.obj
-            while getattr(tmp, '__parent__', None):
-                tmp = tmp.__parent__
-            return tmp
-        return
-
-    def isRoot(self):
-        """Check, whether the wrapped object is the root within its branch.
-
-        This does of course not necessarily mean, it is also the root
-        of the whole instance.
-        """
-        try:
-            return self.getRoot() == self.obj
-        except TypeError:
-            if getattr(self.obj, '__parent__', True) is None:
-                return True
-        return False
-
-    def is_broken(self):
-        """Check, whether the wrapped object is broken.
-        """
-        # XXX to be implemented.
-        return
-
-
-class DCObjectInfo(ObjectInfo_obsolete):
-    """An object wrapper, that provides DublinCore related information.
-
-    If such information is not available (for instance, because the
-    type of object can't be adapted), None is returned for every
-    value. It is therefore safe to use this info type also for objects
-    not supporting DC.
-    """
-    obj = None
-    supports_dc = False
-    _metadata = None
-    _covered_keys = [ 'created', 'modified', 'effective', 'expires',
-                      'publisher', 'creators', 'subjects', 'contributors',
-                      'description', 'title']
-
-
-    def __init__(self, obj):
-
-        super(ObjectInfo, self).__init__(obj)
-        self.obj = obj
-        try:
-            dc = IZopeDublinCore(self.obj)
-            self._metadata = dict((field, getattr(dc, field))
-                                  for field in getFields(IZopeDublinCore) if hasattr(dc, field))
-            self.supports_dc = True
-        except TypeError:
-            # A type error occurs, when obj can't be adapted to
-            # IZopeDublinCore.
-            self._metadata = dict([(x,None) for x in self._covered_keys])
-                
-
-    def _getDCEntry(self, category):
-        if category in self._metadata.keys() and self._metadata[category]:
-            return self._metadata[category]
-        return
-
-
-
-    def getDCMisc(self):
-        """Get dict of DC metadata not covered by other methods.
-        """
-        return dict([x for x in self._metadata.items()
-                     if x[0] not in self.covered_keys])
-
-    def getDCTitle(self):
-        return self._getDCEntry('title') or u''
-
-    def getDCDescription(self):
-        return self._getDCEntry('description') or u''
-
-    def getDCCreators(self):
-        return self._getDCEntry('creators') or ()
-
-    def getDCContributors(self):
-        return self._getDCEntry('contributors') or ()
-
-    def getDCSubjects(self):
-        return self._getDCEntry('subjects') or ()
-
-    def getDCPublisher(self):
-        return self._getDCEntry('publisher') or u''
-
-    def getDCCreationDate(self):
-        return self._getDCEntry('created') or u''
-
-    def getDCModificationDate(self):
-        return self._getDCEntry('modified') or u''
-
-    def getDCEffectiveDate(self):
-        return self._getDCEntry('effective') or u''
-
-    def getDCExpiringDate(self):
-        return self._getDCEntry('expires') or u''
-



More information about the Checkins mailing list