changeset 965:d53ad7bf13e6

Commit with main.
author Alexander Schremmer <alex AT alexanderweb DOT de>
date Sun, 09 Jul 2006 18:31:19 +0200
parents dede3773735c (diff) d59c1af01ccb (current diff)
children 69af0200534e
files MoinMoin/i18n/POTFILES.in MoinMoin/i18n/bg.po MoinMoin/i18n/ca.po MoinMoin/i18n/cs.po MoinMoin/i18n/da.po MoinMoin/i18n/de.po MoinMoin/i18n/en.po MoinMoin/i18n/es.po MoinMoin/i18n/fa.po MoinMoin/i18n/fi.po MoinMoin/i18n/fr.po MoinMoin/i18n/he.po MoinMoin/i18n/hr.po MoinMoin/i18n/hu.po MoinMoin/i18n/it.po MoinMoin/i18n/ja.po MoinMoin/i18n/ko.po MoinMoin/i18n/lv.po MoinMoin/i18n/mo/__init__.py MoinMoin/i18n/mo/bg.MoinMoin.mo MoinMoin/i18n/mo/ca.MoinMoin.mo MoinMoin/i18n/mo/cs.MoinMoin.mo MoinMoin/i18n/mo/da.MoinMoin.mo MoinMoin/i18n/mo/de.MoinMoin.mo MoinMoin/i18n/mo/en.MoinMoin.mo MoinMoin/i18n/mo/es.MoinMoin.mo MoinMoin/i18n/mo/fa.MoinMoin.mo MoinMoin/i18n/mo/fi.MoinMoin.mo MoinMoin/i18n/mo/fr.MoinMoin.mo MoinMoin/i18n/mo/he.MoinMoin.mo MoinMoin/i18n/mo/hr.MoinMoin.mo MoinMoin/i18n/mo/hu.MoinMoin.mo MoinMoin/i18n/mo/it.MoinMoin.mo MoinMoin/i18n/mo/ja.MoinMoin.mo MoinMoin/i18n/mo/ko.MoinMoin.mo MoinMoin/i18n/mo/lv.MoinMoin.mo MoinMoin/i18n/mo/nb.MoinMoin.mo MoinMoin/i18n/mo/nl.MoinMoin.mo MoinMoin/i18n/mo/pl.MoinMoin.mo MoinMoin/i18n/mo/pt.MoinMoin.mo MoinMoin/i18n/mo/pt_br.MoinMoin.mo MoinMoin/i18n/mo/ro.MoinMoin.mo MoinMoin/i18n/mo/ru.MoinMoin.mo MoinMoin/i18n/mo/sl.MoinMoin.mo MoinMoin/i18n/mo/sr.MoinMoin.mo MoinMoin/i18n/mo/sv.MoinMoin.mo MoinMoin/i18n/mo/tr.MoinMoin.mo MoinMoin/i18n/mo/vi.MoinMoin.mo MoinMoin/i18n/mo/zh.MoinMoin.mo MoinMoin/i18n/mo/zh_tw.MoinMoin.mo MoinMoin/i18n/nb.po MoinMoin/i18n/nl.po MoinMoin/i18n/pl.po MoinMoin/i18n/pt.po MoinMoin/i18n/pt_br.po MoinMoin/i18n/ro.po MoinMoin/i18n/ru.po MoinMoin/i18n/sl.po MoinMoin/i18n/sr.po MoinMoin/i18n/sv.po MoinMoin/i18n/tr.po MoinMoin/i18n/vi.po MoinMoin/i18n/zh.po MoinMoin/i18n/zh_tw.po
diffstat 3 files changed, 151 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/util/bdiff.py	Sun Jul 09 18:31:19 2006 +0200
@@ -0,0 +1,93 @@
+"""
+    MoinMoin - Binary patching and diffing
+
+    @copyright: 2005 Matt Mackall <mpm@selenic.com>
+    @copyright: 2006 MoinMoin:AlexanderSchremmer
+    
+    Algorithm taken from mercurial's mdiff.py
+    
+    @license: GNU GPL, see COPYING for details.
+"""
+
+import zlib, difflib, struct
+
+BDIFF_PATT = ">lll"
+BDIFF_PATT_SIZE = struct.calcsize(">lll")
+
+def compress(text):
+    return zlib.compress(text) # here we could tune the compression level
+
+def decompress(bin):
+    return zlib.decompress(bin)
+
+def diff(a, b):
+    """ Generates a binary diff of the passed strings.
+        Note that you can pass arrays of strings as well.
+        This might give you better results for text files. """
+    if not a:
+        s = "".join(b)
+        return s and (struct.pack(BDIFF_PATT, 0, 0, len(s)) + s)
+
+    bin = []
+    la = lb = 0
+    
+    p = [0]
+    for i in a: p.append(p[-1] + len(i))
+    
+    for am, bm, size in difflib.SequenceMatcher(None, a, b).get_matching_blocks():
+        s = "".join(b[lb:bm])
+        if am > la or s:
+            bin.append(struct.pack(BDIFF_PATT, p[la], p[am], len(s)) + s)
+        la = am + size
+        lb = bm + size
+    
+    return "".join(bin)
+
+def textdiff(a, b):
+    """ A diff function optimised for text files. Works with binary files as well. """
+    return diff(a.splitlines(1), b.splitlines(1))
+
+def patchtext(bin):
+    """ Returns the new hunks that are contained in a binary diff."""
+    pos = 0
+    t = []
+    while pos < len(bin):
+        p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + BDIFF_PATT_SIZE])
+        pos += BDIFF_PATT_SIZE
+        t.append(bin[pos:pos + l])
+        pos += l
+    return "".join(t)
+
+def patch(a, bin):
+    """ Patches the string a with the binary patch bin. """
+    c = last = pos = 0
+    r = []
+
+    while pos < len(bin):
+        p1, p2, l = struct.unpack(BDIFF_PATT, bin[pos:pos + BDIFF_PATT_SIZE])
+        pos += BDIFF_PATT_SIZE
+        r.append(a[last:p1])
+        r.append(bin[pos:pos + l])
+        pos += l
+        last = p2
+        c += 1
+    r.append(a[last:])
+
+    return "".join(r)
+
+def test():
+    a = ("foo\n" * 30)
+    b = ("  fao" * 30)
+    
+    a = file(r"C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Progra\Python\MoinMoin\moin-1.6-sync\MoinMoin\util\test.1").read()
+    b = file(r"C:\Dokumente und Einstellungen\Administrator\Eigene Dateien\Progra\Python\MoinMoin\moin-1.6-sync\MoinMoin\util\test.2").read()
+    a = a.splitlines(1)
+    b = b.splitlines(1)
+    
+    d = diff(a, b)
+    z = compress(d)
+    print `patchtext(d)`
+    print `d`
+    print "".join(b) == patch("".join(a), d)
+    print len(d), len(z)
+
--- a/MoinMoin/xmlrpc/__init__.py	Sun Jul 09 15:31:02 2006 +0200
+++ b/MoinMoin/xmlrpc/__init__.py	Sun Jul 09 18:31:19 2006 +0200
@@ -493,18 +493,47 @@
                 for hit in results.hits]
 
     def xmlrpc_getMoinVersion(self):
+        """ Returns a tuple of the MoinMoin version:
+            (project, release, revision)
+        """
         from MoinMoin import version
         return (version.project, version.release, version.revision)
 
-
+    # authorization methods
+    
+    def xmlrpc_getAuthToken(self, username, password, *args):
+        """ Returns a token which can be used for authentication
+            in other XMLRPC calls. If the token is empty, the username
+            or the password were wrong. """
+        u = user.User(self.request, name=username, password=password, auth_method='xmlrpc_gettoken')
+        if u.valid:
+            return u.id
+        else:
+            return ""
+    
+    def xmlrpc_applyAuthToken(self, auth_token):
+        """ Applies the auth token and thereby authenticates the user. """
+        u = user.User(self.request, id=auth_token, auth_method='xmlrpc_applytoken')
+        if u.valid:
+            self.request.user = u
+            return "SUCCESS"
+        else:
+            raise Exception("Invalid token.") # XXX make a distinct class
+    
+    def xmlrpc_getDiff(self, pagename, from_rev, to_rev):
+        return "NOT_IMPLEMENTED_YET"
+        
     # XXX BEGIN WARNING XXX
     # All xmlrpc_*Attachment* functions have to be considered as UNSTABLE API -
     # they are neither standard nor are they what we need when we have switched
     # attachments (1.5 style) to mimetype items (hopefully in 1.6).
-    # They are likely to get removed again when we remove AttachFile module.
-    # So use them on your own risk.
+    # They will be partly removed, esp. the semantics of the function "listAttachments"
+    # cannot be sensibly defined for items.
+    # If the first beta or more stable release of 1.6 will have new item semantics,
+    # we will remove the functions before it is released.
     def xmlrpc_listAttachments(self, pagename):
         """ Get all attachments associated with pagename
+        Deprecated.
         
         @param pagename: pagename (utf-8)
         @rtype: list
--- a/docs/CHANGES.aschremmer	Sun Jul 09 15:31:02 2006 +0200
+++ b/docs/CHANGES.aschremmer	Sun Jul 09 18:31:19 2006 +0200
@@ -6,12 +6,15 @@
 
   ToDo:
     * Implement actual syncronisation.
-    * Implement a cross-site authentication system.
+    * Implement a cross-site authentication system, i.e. mainly an
+      identity storage.
 
   New Features:
     * XMLRPC method to return the Moin version
     * XMLRPC multicall support
     * Conflict icon in RecentChanges
+    * XMLRPC Authentication System
+    * Binary Diffing
 
   Bugfixes (only stuff that is buggy in moin/1.6 main branch):
     * ...
@@ -22,11 +25,30 @@
   Developer notes:
     * ...
 
+Do not forget to check the related wiki page: http://moinmoin.wikiwikiweb.de/WikiSyncronisation
 
 Diary
 =====
 
-Week 21: Basic Infrastructur setup (repos), initial talks to the mentor, started writing the design document, helped other students to get started, started evaluating Mercurial as a DVCS backend
-Week 22: Tax forms, Fulfilled transcription request, written conflict icon support, refactored conflict handling, changed conflict icon, Added xmlrpc multicall support into the server and backported the client code from python 2.4
+Week 21: Basic Infrastructur setup (repos),
+         initial talks to the mentor, started writing the design document,
+         helped other students to get started
+Week 22: Tax forms, Fulfilled transcription request,
+         written conflict icon support, refactored conflict handling,
+         changed conflict icon,
+         Added xmlrpc multicall support into the server and
+         backported the client code from python 2.4
+Week 23: Debian-Sprint in Extremadura, Spain. Initial thoughts about Mercurial as a base for syncronisation.
+Week 24: Evaluation of OpenID as a base for authentication, written local testing scripts
+Week 25: Conference in Chile.
+Week 26: Implementation of the XMLRPC authentication system, added binary
+         diffing (mainly taken from Mercurial, but had to merge 5 changesets,
+         remove some mercurial dependencies and document it. Currently, Mercurial
+         uses a module written in C to solve the problem, so the Python code
+         was not cared for anymore.)
 
-
+Time plan
+=========
+In July and August, most parts of the implementation will be finished
+from 07-10 to 07-14 and from 08-03 to 08-19. Between those time spans, there
+are exams.