[Checkins] SVN: Sandbox/ulif/grok-adminui/src/grok/admin/ Get rid
of superfluous functions in docgrok.
Uli Fouquet
uli at gnufix.de
Tue Jul 10 07:29:50 EDT 2007
Log message for revision 77677:
Get rid of superfluous functions in docgrok.
Changed:
U Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py
U Sandbox/ulif/grok-adminui/src/grok/admin/view.py
-=-
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py 2007-07-10 11:25:17 UTC (rev 77676)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/docgrok.py 2007-07-10 11:29:49 UTC (rev 77677)
@@ -181,7 +181,6 @@
except:
return None
-
for handler in docgrok_handlers:
spec_handler = handler['handler']
doc_grok = spec_handler( dotted_path, ob )
@@ -291,62 +290,7 @@
'handler':obj})
return True
-
-## XXX deprecated...
-def getThingsType( dotted_path ):
- """Determine type of thing described by a dotted path.
-
- None for: thing does not exist/is not accessible by resolve().
-
- 'package' for: python package.
- 'unknown' for: exists, but no special doctor for this desease.
- """
- try:
- ob = resolve( dotted_path )
- except ImportError:
- # There is no package of that name. Give back 404.
- # XXX Do something more intelligent, offer a search.
- return None
- except:
- return None
-
- if hasattr( ob, "__file__" ) and is_package(os.path.dirname(ob.__file__)):
- if os.path.basename(ob.__file__) in ['__init__.py',
- '__init__.pyc']:
- return "package"
- return "module"
- elif isinstance(removeAllProxies(ob), InterfaceClass):
- return "interface"
- elif inspect.isclass(ob):
- return "class"
- return "unknown"
-
-
-def getDocGrokForDottedPath_obsolete( dotted_path ):
- """Find a doctor, which is a specialist for the dotted path element.
- """
- return handle(dotted_path)
- newtype = getThingsType( dotted_path )
- if newtype is None:
- # There is nothing of that name. Give back 404.
- # XXX Do something more intelligent, offer a search.
- return None
- elif newtype == "package":
- # We found a package. Let a DocGrokPackage handle further
- # things.
- doctor = DocGrokPackage( dotted_path )
- elif newtype == "module":
- doctor = DocGrokModule(dotted_path)
- elif newtype == "interface":
- doctor = DocGrokInterface(dotted_path)
- elif newtype == "class":
- doctor = DocGrokClass(dotted_path)
- else:
- doctor = DocGrok( dotted_path ) # Default
- return doctor
-
-
class DocGrok(grok.Model):
"""DocGrok helps us finding out things about ourselves.
Modified: Sandbox/ulif/grok-adminui/src/grok/admin/view.py
===================================================================
--- Sandbox/ulif/grok-adminui/src/grok/admin/view.py 2007-07-10 11:25:17 UTC (rev 77676)
+++ Sandbox/ulif/grok-adminui/src/grok/admin/view.py 2007-07-10 11:29:49 UTC (rev 77677)
@@ -1,6 +1,6 @@
import grok
import os
-from grok.admin.docgrok import DocGrok, DocGrokPackage, DocGrokModule, getThingsType
+from grok.admin.docgrok import DocGrok, DocGrokPackage, DocGrokModule
from grok.admin.docgrok import DocGrokClass, DocGrokInterface, DocGrokGrokApplication
from grok.admin.docgrok import DocGrokTextFile
@@ -217,27 +217,47 @@
"""
if not hasattr(self.context, "apidoc") or not hasattr(self.context.apidoc, "items"):
return None
- entries = [{'name': name,
- 'obj' : obj,
- 'doc' : (
- hasattr(obj,"getDocString") and self.getDocHeading(obj.getDocString())) or (
- hasattr(obj, "getDoc") and isinstance(
- removeAllProxies(obj), InterfaceClass) and self.getDocHeading(obj.getDoc())) or None,
- # only for interfaces; should be done differently somewhen
- 'path': getPythonPath(removeAllProxies(obj)),
- 'url': ("%s/%s" % (self.context.path.replace('.','/'), name)),
- 'ispackage': getThingsType(
- "%s.%s" % (self.context.path,name) ) == "package",
- 'ismodule': getThingsType(
- "%s.%s" % (self.context.path,name) ) == "module",
- 'isinterface': isinstance(
- removeAllProxies(obj), InterfaceClass),
- 'isclass': isinstance(obj, Class),
- 'isfunction': isinstance(obj, Function),
- 'signature' : isinstance(obj, Function) and obj.getSignature() or None,
- 'istextfile': isinstance(obj, TextFile),
- 'iszcmlfile': isinstance(obj, ZCMLFile)}
- for name, obj in self.context.apidoc.items()]
+ entries = []
+ for name, obj in self.context.apidoc.items():
+ entry = {
+ 'name': name,
+ 'obj' : obj,
+ 'path': getPythonPath(removeAllProxies(obj)),
+ 'url' : u'',
+ 'doc' : None,
+ 'ispackage' : False,
+ 'ismodule' : False,
+ 'isinterface' : False,
+ 'isclass' : False,
+ 'isfunction' : False,
+ 'istextfile' : False,
+ 'iszcmlfile' : False,
+ 'signature' : None
+ }
+ entry['url'] = "%s/%s" % (self.context.path.replace('.','/'), name)
+ if hasattr(obj,"getDocString"):
+ entry['doc'] = self.getDocHeading(obj.getDocString())
+ elif hasattr(obj, "getDoc") and isinstance(
+ removeAllProxies(obj), InterfaceClass):
+ entry['doc'] = self.getDocHeading(obj.getDoc())
+ if isinstance(obj, Class):
+ entry['isclass'] = True
+ elif isinstance(obj, TextFile):
+ entry['istextfile'] = True
+ elif isinstance(obj, ZCMLFile):
+ entry['iszcmlfile'] = True
+ elif isinstance(obj,Function):
+ entry['isfunction'] = True
+ if hasattr(obj, 'getSignature'):
+ entry['signature'] = obj.getSignature()
+ elif isinstance(obj,Module) and os.path.basename(obj.getFileName()) in [
+ '__init.py__', '__init__.pyc', '__init__.pyo'
+ ]:
+ entry['ispackage'] = True
+ elif isinstance(obj,Module):
+ entry['ismodule'] = True
+ entries.append(entry)
+
entries.sort(lambda x, y: cmp(x['name'], y['name']))
#if columns:
# entries = columnize(entries)
More information about the Checkins
mailing list