[Checkins] SVN: Sandbox/luciano/kirbi/src/kirbi/ revising docstrings

Luciano Ramalho luciano at ramalho.org
Tue Aug 14 12:32:02 EDT 2007


Log message for revision 78811:
  revising docstrings
  

Changed:
  U   Sandbox/luciano/kirbi/src/kirbi/app.py
  U   Sandbox/luciano/kirbi/src/kirbi/app_templates/index.pt
  U   Sandbox/luciano/kirbi/src/kirbi/book.py
  U   Sandbox/luciano/kirbi/src/kirbi/pac.py
  U   Sandbox/luciano/kirbi/src/kirbi/user.py

-=-
Modified: Sandbox/luciano/kirbi/src/kirbi/app.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/app.py	2007-08-14 15:44:04 UTC (rev 78810)
+++ Sandbox/luciano/kirbi/src/kirbi/app.py	2007-08-14 16:32:02 UTC (rev 78811)
@@ -4,16 +4,17 @@
 from kirbi.book import Book
 from kirbi.user import UserFolder
 from zope.interface import Interface, implements
+from zope.component import getSiteManager
 
 class Kirbi(grok.Application, grok.Container):
-    """ Peer-to-peer library system """
+    """Peer-to-peer library system."""
     def __init__(self):
         super(Kirbi, self).__init__()
         self['pac'] = Pac()
-        self['u'] = UserFolder()
+        self.userFolder = self['u'] = UserFolder()
 
 class Index(grok.View):
-    pass # see app_templates/index.pt
+    pass
 
 class BookIndexes(grok.Indexes):
     grok.site(Kirbi)
@@ -28,5 +29,5 @@
     creatorsSet = index.Set()
     
 class Master(grok.View):
-    """ The master page template macro """
+    """The master page template macro."""
     grok.context(Interface)

Modified: Sandbox/luciano/kirbi/src/kirbi/app_templates/index.pt
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/app_templates/index.pt	2007-08-14 15:44:04 UTC (rev 78810)
+++ Sandbox/luciano/kirbi/src/kirbi/app_templates/index.pt	2007-08-14 16:32:02 UTC (rev 78811)
@@ -9,6 +9,11 @@
 
   Main page stuff will be here.
   
+  <div tal:content="view/request/principal/id" />
+
+  <div tal:content="python:view.getSite()['kirbi']" />
+
+  
   </div>	
 </body>
 </html>

Modified: Sandbox/luciano/kirbi/src/kirbi/book.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/book.py	2007-08-14 15:44:04 UTC (rev 78810)
+++ Sandbox/luciano/kirbi/src/kirbi/book.py	2007-08-14 16:32:02 UTC (rev 78811)
@@ -27,6 +27,7 @@
         return True
 
 class IBook(Interface):
+    """A book record"""
     title = schema.TextLine(title=u"Title",
                             required=False,
                             default=u'',
@@ -71,8 +72,7 @@
             raise Invalid('Either the title or the ISBN must be given.')
 
 class Book(grok.Model):
-    """
-    A book record.
+    """A book record implementation.
 
     >>> alice = Book()
     >>> alice.title = u"Alice's Adventures in Wonderland"
@@ -98,7 +98,6 @@
     >>> won.setFilingTitle()
     >>> won.filing_title
     u'Wealth of Networks, The: How Social Production...'
-
     """
 
     implements(IBook)

Modified: Sandbox/luciano/kirbi/src/kirbi/pac.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/pac.py	2007-08-14 15:44:04 UTC (rev 78810)
+++ Sandbox/luciano/kirbi/src/kirbi/pac.py	2007-08-14 16:32:02 UTC (rev 78811)
@@ -14,16 +14,16 @@
 from time import localtime, strftime
 
 class Pac(grok.Container):
-    """ Pac (public access catalog)
+    """Pac (public access catalog)
 
-        Bibliographic records for all items (books, disks etc.) known to this
-        Kirbi instance. The contents of this catalog is public, but information
-        about item ownership and availability is not kept here.
-
-        In library science the term "catalog" is used to refer to
-        "a comprehensive list of the materials in a given collection".
-        The Pac name was chosen to avoid confusion with zc.catalog.
-        The Pac is not an instance of a Zope catalog, but will use one.
+    Bibliographic records for all items (books, disks etc.) known to this
+    Kirbi instance. The contents of this catalog is public, but information
+    about item ownership and availability is not kept here.
+    
+    In library science the term "catalog" is used to refer to
+    "a comprehensive list of the materials in a given collection".
+    The Pac name was chosen to avoid confusion with zc.catalog.
+    The Pac is not an instance of a Zope catalog, but will use one.
     """
 
     def __init__(self):
@@ -184,12 +184,16 @@
     implements(INameChooser)
 
     def nextId(self,fmt='%s'):
-        """ Binary search to quickly find an unused numbered key, useful
-            when importing many books without ISBN. The algorithm generates a
-            key right after the largest numbered key or in some unused lower
-            numbered slot found by the second loop. If keys are later deleted
-            in random order, some of the resulting slots will be reused and
-            some will not.
+        """Binary search to quickly find an unused numbered key.
+        
+        This was designed to scale well when importing large batches of books
+        without ISBN, while keeping the ids short.
+        
+        The algorithm generates a key right after the largest numbered key or
+        in some unused lower numbered slot found by the second loop.
+        
+        If keys are later deleted in random order, some of the resulting slots
+        will be reused and some will not.
         """
         i = 1
         while fmt%i in self.context:

Modified: Sandbox/luciano/kirbi/src/kirbi/user.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/user.py	2007-08-14 15:44:04 UTC (rev 78810)
+++ Sandbox/luciano/kirbi/src/kirbi/user.py	2007-08-14 16:32:02 UTC (rev 78811)
@@ -7,8 +7,8 @@
 class UserFolder(grok.Container):
     pass
 
-
 class IUser(Interface):
+    """A Kirbi user"""
     login = schema.TextLine(title=u"Login",
                             required=True)
     name = schema.TextLine(title=u"Name",
@@ -17,8 +17,9 @@
                             required=True)
     
 class User(grok.Container):
-    """
-    A Kirbi user. A User will contain Copy instances, representing book copies
+    """A Kirbi user implementation.
+    
+    A User will contain Copy instances, representing book copies
     owned by the user.
     
         >>> alice = User('alice', u'Alice Cooper', u'headless-chicken')
@@ -28,7 +29,6 @@
         'f030ff587c602e0e9a68aba75f41c51a0dc22c62'
         >>> alice.name_and_login()
         u'Alice Cooper (alice)'
-
     """
 
     implements(IUser)
@@ -52,7 +52,6 @@
         else:
             return self.login
 
-
 class PrincipalInfoAdapter(grok.Adapter):
     grok.context(User)
     grok.implements(IPrincipalInfo)
@@ -84,11 +83,10 @@
     grok.context(UserFolder)
     def update(self, query=None):
         self.results_title = '%d users' % len(self.context)
-
     
 class Register(grok.AddForm):
     grok.context(UserFolder)
-    """ User registration form """
+    """User registration form"""
     
     form_fields = grok.AutoFields(IUser)
 



More information about the Checkins mailing list