upgrade lucene
authorymh <ymh.work@gmail.com>
Tue, 08 Jun 2010 15:10:46 +0200
changeset 3 651f67b66c51
parent 2 252f2e87cdc3
child 4 7c994c98d1df
upgrade lucene
.pydevproject
web/eulalie/config.py.tmpl
web/eulalie/settings.py
web/ldt/ldt/__init__.py
web/ldt/ldt/admin.py
web/ldt/ldt/contentindexer.py
web/ldt/ldt/fileimport.py
web/ldt/ldt/models.py
web/ldt/ldt/templates/admin/ldt/app_action.html
web/ldt/ldt/templates/admin/ldt/app_index.html
web/ldt/ldt/templates/admin/ldt/content/reindex_form.html
web/ldt/ldt/templates/admin/ldt/content/search_form.html
web/ldt/ldt/templates/admin/ldt/content/upload_form.html
web/ldt/ldt/templates/iriuser/ldt/copy_ldt.html
web/ldt/ldt/templates/iriuser/ldt/create_ldt.html
web/ldt/ldt/templates/iriuser/ldt/init_ldt.html
web/ldt/ldt/templates/iriuser/ldt/ldt_list.html
web/ldt/ldt/templates/iriuser/ldt/loading.html
web/ldt/ldt/templates/iriuser/ldt/save_done.html
web/ldt/ldt/utils.py
web/ldt/settings.py
--- a/.pydevproject	Tue Jun 08 13:39:41 2010 +0200
+++ b/.pydevproject	Tue Jun 08 15:10:46 2010 +0200
@@ -2,6 +2,6 @@
 <?eclipse-pydev version="1.0"?>
 
 <pydev_project>
-<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python_eulalie</pydev_property>
 <pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.6</pydev_property>
 </pydev_project>
--- a/web/eulalie/config.py.tmpl	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/eulalie/config.py.tmpl	Tue Jun 08 15:10:46 2010 +0200
@@ -60,3 +60,4 @@
 ACCOUNT_ACTIVATION_DAYS = 7
 REGISTRATION_OPEN = False
 
+LDT_MAX_SEARCH_NUMBER = 50
--- a/web/eulalie/settings.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/eulalie/settings.py	Tue Jun 08 15:10:46 2010 +0200
@@ -132,6 +132,6 @@
 LOGOUT_URL = BASE_URL + 'eulalie'
 ACCOUNT_ACTIVATION_DAYS = 7 
 
+LDT_MAX_SEARCH_NUMBER = 50
 
 
-
--- a/web/ldt/ldt/__init__.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/__init__.py	Tue Jun 08 15:10:46 2010 +0200
@@ -3,12 +3,13 @@
 
 lucene.initVM(lucene.CLASSPATH)
 
-STORE = lucene.FSDirectory.getDirectory(settings.INDEX_PATH, False)
-ANALYZER = lucene.PerFieldAnalyzerWrapper(lucene.StandardAnalyzer())
-ANALYZER.addAnalyzer("tags",lucene.FrenchAnalyzer())
-ANALYZER.addAnalyzer("title",lucene.FrenchAnalyzer())
-ANALYZER.addAnalyzer("abstract",lucene.FrenchAnalyzer())
-ANALYZER.addAnalyzer("all",lucene.FrenchAnalyzer())
+STORE = lucene.SimpleFSDirectory(lucene.File(settings.INDEX_PATH))
+ANALYZER = lucene.PerFieldAnalyzerWrapper(lucene.StandardAnalyzer(lucene.Version.LUCENE_CURRENT))
+ANALYZER.addAnalyzer("tags",lucene.FrenchAnalyzer(lucene.Version.LUCENE_CURRENT))
+ANALYZER.addAnalyzer("title",lucene.FrenchAnalyzer(lucene.Version.LUCENE_CURRENT))
+ANALYZER.addAnalyzer("abstract",lucene.FrenchAnalyzer(lucene.Version.LUCENE_CURRENT))
+ANALYZER.addAnalyzer("all",lucene.FrenchAnalyzer(lucene.Version.LUCENE_CURRENT))
+
 
 VERSION  = (0,1)
 VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION)))
--- a/web/ldt/ldt/admin.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/admin.py	Tue Jun 08 15:10:46 2010 +0200
@@ -49,8 +49,7 @@
             form = ReindexForm(request.POST)
             if form.is_valid():    
                 # try:
-                writer = lucene.IndexWriter(STORE, ANALYZER, True)
-                writer.setMaxFieldLength(1048576)
+                writer = lucene.IndexWriter(STORE, ANALYZER, True, lucene.IndexWriter.MaxFieldLength.UNLIMITED)
                 contentList = form.cleaned_data["contents"]
                 indexer = ContentIndexer(contentList,writer)
                 indexer.index_all()
--- a/web/ldt/ldt/contentindexer.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/contentindexer.py	Tue Jun 08 15:10:46 2010 +0200
@@ -14,6 +14,7 @@
 import xml.dom.ext
 import xml.xpath
 import fnmatch
+import Ft
 import uuid
 import shutil
 import lucene
@@ -56,25 +57,26 @@
             url =content.iri_url()
             filepath = urllib.urlopen(url)
             doc = xml.dom.minidom.parse(filepath)
-                                    
+            doc = Ft.Xml.Domlette.ConvertDocument(doc)
+                                   
             self.__writer.deleteDocuments(lucene.Term("iri_id", content.iri_id))
             
             con = xml.xpath.Context.Context(doc, 1, 1, None)
             res = xml.xpath.Evaluate("/iri/body/ensembles/ensemble", context=con)
 
             for ensemble in res:
-                ensembleId = ensemble.getAttribute("id")
+                ensembleId = ensemble.getAttributeNS("id",None)
                 
                 for decoupageNode in ensemble.childNodes:
-                    if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttribute("id") in self.decoupage_blacklist:
+                    if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttributeNS("id",None) in self.decoupage_blacklist:
                         continue
                     
-                    decoupId = decoupageNode.getAttribute("id")
+                    decoupId = decoupageNode.getAttributeNS("id",None)
                     res = xml.xpath.Evaluate("elements/element", decoupageNode)
                     for elementNode in res:
                         doc = lucene.Document()
-                        elementId = elementNode.getAttribute("id")
-                        tags = elementNode.getAttribute("tags")
+                        elementId = elementNode.getAttributeNS("id",None)
+                        tags = elementNode.getAttributeNS("tags",None)
                         
                         if tags is not None:                            
                             tags.replace(",", ";")
@@ -99,18 +101,33 @@
                         for txtRes in xml.xpath.Evaluate("abstract/text()", elementNode): 
                             abstract = abstract + txtRes.data 
                 
-                        doc.add(lucene.Field("iri_id", content.iri_id, lucene.Field.Store.YES, lucene.Field.Index.UN_TOKENIZED))
+                        doc.add(lucene.Field("iri_id", content.iri_id, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED))
                         doc.add(lucene.Field("ensemble_id", ensembleId, lucene.Field.Store.YES, lucene.Field.Index.NO))
                         doc.add(lucene.Field("decoupage_id", decoupId, lucene.Field.Store.YES, lucene.Field.Index.NO))
-                        doc.add(lucene.Field("element_id", elementId, lucene.Field.Store.YES, lucene.Field.Index.NO))
-                        doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
+                        doc.add(lucene.Field("element_id", elementId, lucene.Field.Store.YES, lucene.Field.Index.NO))                        
+                        doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+
+                        seg = Segment(content=content,
+                                      iri_id=content.iri_id,
+                                      ensemble_id=ensembleId,
+                                      cutting_id=decoupId,
+                                      element_id=elementId,
+                                      tags=tags,
+                                      title=title,
+                                      abstract=abstract,
+                                      duration=duration,
+                                      author=author,
+                                      start_ts=start_ts,
+                                      date=date_str)
+                        seg.save()
+
             
                         self.__writer.addDocument(doc)
             
-            self.__writer.flush()
+            self.__writer.commit()
             
             
 class ProjectIndexer(object):
@@ -145,6 +162,7 @@
             
             # pocketfilms.utils.log.debug("Indexing project : "+str(project.iri_id))
             doc = xml.dom.minidom.parseString(project.ldt)
+            doc = Ft.Xml.Domlette.ConvertDocument(doc) 
 
             self.__writer.deleteDocuments(lucene.Term("iri_id", project.iri_id))
             
@@ -152,21 +170,21 @@
             res = xml.xpath.Evaluate("/iri/annotations/content", context=con)
 
             for content in res:
-                contentId = content.getAttribute("id")
+                contentId = content.getAttributeNS("id",None)
                 
                 ensembleId = "ens_perso"
                 
                 for decoupageNode in content.childNodes:
                     # pocketfilms.utils.log.debug("Indexing content decoupage : "+ repr(decoupageNode.nodeType) + " in " + repr(self.decoupage_blacklist))
-                    if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttribute("id") in self.decoupage_blacklist:
+                    if decoupageNode.nodeType != xml.dom.Node.ELEMENT_NODE or decoupageNode.tagName != "decoupage"  or decoupageNode.getAttributeNS("id",None) in self.decoupage_blacklist:
                         continue
                     
-                    decoupId = decoupageNode.getAttribute("id")
+                    decoupId = decoupageNode.getAttributeNS("id",None)
                     res = xml.xpath.Evaluate("elements/element", decoupageNode)
                     for elementNode in res:
                         doc = lucene.Document()
-                        elementId = elementNode.getAttribute("id")
-                        tags = elementNode.getAttribute("tags")
+                        elementId = elementNode.getAttributeNS("id",None)
+                        tags = elementNode.getAttributeNS("tags",None)
                         
                         if tags is not None:                            
                             tags.replace(",", ";")
@@ -191,16 +209,30 @@
                         for txtRes in xml.xpath.Evaluate("abstract/text()", elementNode): 
                             abstract = abstract + txtRes.data 
                 
-                        doc.add(lucene.Field("project_id", project.iri_id, lucene.Field.Store.YES, lucene.Field.Index.UN_TOKENIZED))              
-                        doc.add(lucene.Field("iri_id", contentId, lucene.Field.Store.YES, lucene.Field.Index.UN_TOKENIZED))
+                        doc.add(lucene.Field("project_id", project.iri_id, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED))              
+                        doc.add(lucene.Field("iri_id", contentId, lucene.Field.Store.YES, lucene.Field.Index.NOT_ANALYZED))
                         doc.add(lucene.Field("ensemble_id", ensembleId, lucene.Field.Store.YES, lucene.Field.Index.NO))
                         doc.add(lucene.Field("decoupage_id", decoupId, lucene.Field.Store.YES, lucene.Field.Index.NO))
                         doc.add(lucene.Field("element_id", elementId, lucene.Field.Store.YES, lucene.Field.Index.NO))
-                        doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-                        doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.TOKENIZED))
-            
+                        doc.add(lucene.Field("tags", tags, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("title", title, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("abstract", abstract, lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        doc.add(lucene.Field("all", " ".join([tags, title, abstract]), lucene.Field.Store.NO, lucene.Field.Index.ANALYZED))
+                        
+                        seg = Segment(content=content,
+                                      iri_id=content.iri_id,
+                                      ensemble_id=ensembleId,
+                                      cutting_id=decoupId,
+                                      element_id=elementId,
+                                      tags=tags,
+                                      title=title,
+                                      abstract=abstract,
+                                      duration=duration,
+                                      author=author,
+                                      start_ts=start_ts,
+                                      date=date_str)
+                        seg.save()
+                                    
                         self.__writer.addDocument(doc)
             
-            self.__writer.flush()
+            self.__writer.commit()
--- a/web/ldt/ldt/fileimport.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/fileimport.py	Tue Jun 08 15:10:46 2010 +0200
@@ -35,6 +35,7 @@
         self.videourl = ""
         self.title = None
         self.desc = None
+        self.duration = None
         self.created = False
         self.content = None
         self.decoupage_blacklist = decoupage_blacklist
@@ -48,7 +49,8 @@
         # for just import a file ldt and get the title for every media
         if 'http' in self.src:
             url = urllib.urlopen(self.src)
-            doc = xml.dom.minidom.parse(url)            
+            doc = xml.dom.minidom.parse(url)
+            doc = Ft.Xml.Domlette.ConvertDocument(doc)             
             con = xml.xpath.Context.Context(doc, 1, 1, None)
             #open .iri and get the title
             res = xml.xpath.Evaluate("/iri/head/meta[@name='title']/@content", context=con)
@@ -71,7 +73,7 @@
 
         for node in ensemblesnode.childNodes:
             if node.nodeType == xml.dom.Node.ELEMENT_NODE and node.tagName == "ensemble":
-                id = node.getAttribute("id")
+                id = node.getAttributeNS("id",None)
                 if id not in ensembleids:
                     ensembleids.append(id)
 
@@ -82,12 +84,12 @@
                     if newEnsemble is None:
                         newensemble = doc.createElement('ensemble')
                         ensembleid = self.id+"_"+str(uuid.uuid1())
-                        newensemble.setAttribute('id',ensembleid)
+                        newensemble.setAttributeNS(None,'id',ensembleid)
             
-                        newensemble.setAttribute('title', self.annotations.getAttribute('title'))
-                        newensemble.setAttribute('author', self.annotations.getAttribute('author'))
-                        newensemble.setAttribute('date', self.annotations.getAttribute('date'))
-                        newensemble.setAttribute('abstract', self.annotations.getAttribute('abstract'))
+                        newensemble.setAttributeNS(None,'title', self.annotations.getAttribute('title'))
+                        newensemble.setAttributeNS(None,'author', self.annotations.getAttribute('author'))
+                        newensemble.setAttributeNS(None,'date', self.annotations.getAttribute('date'))
+                        newensemble.setAttributeNS(None,'abstract', self.annotations.getAttribute('abstract'))
                         ensemblesnode.appendChild(newensemble)
                         ensembleids.append(ensembleid)
                     newDecoupageNode = cnode.cloneNode(True)
@@ -101,11 +103,12 @@
                     ensembleids.append(ensembleid)
                     ensemblesnode.appendChild(cloneNode)
 
+        res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
         if self.flatten:
-            res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
             src_video = res[0].getAttribute('src')
             self.videourl = os.path.basename(src_video)
-            res[0].setAttribute('src', self.videourl)
+            res[0].setAttributeNS(None,'src', self.videourl)
+        self.duration = res[0].getAttributeNS(None, 'dur')
             
         f = open(path, "w")
         try:
@@ -140,6 +143,7 @@
         content.iri = self.id + u"/" + os.path.basename(self.src)
         content.title = self.title
         content.description = self.desc
+        content.duration = int(self.duration)
         content.save()
 
         self.content = content
@@ -262,7 +266,7 @@
         #get author from file ldt
         result = xml.xpath.Evaluate("/iri/project", context=con)
         for pnode in result:
-            author = pnode.getAttribute("user")
+            author = pnode.getAttributeNS("user",None)
             if author:
                 self.author = unicode(author)
                 break 
@@ -305,7 +309,7 @@
             # pocketfilms.utils.log.debug("ID : " + str(id))
             if contents.has_key(id):
                 if self.author:
-                    contentnode.setAttribute("author", unicode(self.author))
+                    contentnode.setAttributeNS(None,"author", unicode(self.author))
                 contents[id].annotations = contentnode
         
         #go throught values
--- a/web/ldt/ldt/models.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/models.py	Tue Jun 08 15:10:46 2010 +0200
@@ -5,6 +5,17 @@
 from utils import create_ldt, copy_ldt
 import uuid
 
+class Author(models.Model):
+
+    handle = models.CharField(max_length=512, unique=True, blank=True, null=True)
+    email = models.EmailField(unique=False, blank=True, null=True)
+    firstname = models.CharField(max_length=512, blank=True, null=True)
+    lastname = models.CharField(max_length=512, blank=True, null=True)
+    
+    def __unicode__(self):
+        return unicode(self.id) + " - " + self.handle + ", " + self.email + ", " + self.firstname + " " + self.lastname
+
+
 class Content(models.Model):
     iri_id = models.CharField(max_length=1024, unique=True)
     iriurl = models.URLField()
@@ -14,7 +25,24 @@
     title = models.CharField(max_length=1024, null=True, blank=True)
     description = models.TextField(null=True, blank=True)
     external_id = models.CharField(max_length=1024, null=True, blank=True)
-    # authors = models.ManyToManyField(Author)
+    authors = models.ManyToManyField(Author)
+    duration = models.IntegerField(null=True, blank=True)
+
+    def get_duration(self):
+        if self.duration is None:
+            doc = xml.dom.minidom.parse(self.iri_file_path())
+            doc = Ft.Xml.Domlette.ConvertDocument(doc)        
+            con = xml.xpath.Context.Context(doc, 1, 1, None)
+            res = xml.xpath.Evaluate("/iri/body/medias/media[@id='video']/video", context=con)
+            self.duration = int(res[0].getAttributeNS(None, 'dur'))
+            self.save()
+        return self.duration
+    
+    def delete(self):
+        super(Content, self).delete()
+        writer = lucene.IndexWriter(STORE, ANALYZER, True, lucene.IndexWriter.MaxFieldLength.UNLIMITED)
+        writer.deleteDocuments(lucene.Term("iri_id", self.iri_id))
+        writer.commit() 
     
     def __unicode__(self):
         return str(self.id) + ": " + self.iri_id
@@ -71,3 +99,26 @@
         project.save()
         return project
 
+class Segment(models.Model):
+    
+    project_obj = models.ForeignKey(Project, null=True)
+    content = models.ForeignKey(Content)
+    project_id = models.CharField(max_length=1024, unique=False, blank=True, null=True)
+    iri_id = models.CharField(max_length=1024, unique=False)
+    ensemble_id = models.CharField(max_length=1024, unique=False)
+    cutting_id = models.CharField(max_length=1024, unique=False)    
+    element_id = models.CharField(max_length=1024, unique=False)
+    tags = models.CharField(max_length=2048, unique=False, null=True, blank=True)  
+    title = models.CharField(max_length=2048, unique=False, null=True, blank=True)
+    duration = models.IntegerField(null=True)
+    start_ts = models.IntegerField(null=True)
+    author = models.CharField(max_length=1024, unique=False, null=True, blank=True)
+    date = models.CharField(max_length=128, unique=False, null=True, blank=True)
+    abstract = models.TextField(null=True, blank=True)
+    
+    def __unicode__(self):
+        return "/".join((unicode(self.project_id), unicode(self.iri_id), unicode(self.ensemble_id), unicode(self.cutting_id), unicode(self.element_id)))
+    
+    class Meta:
+        unique_together = (('project_id', 'iri_id', 'ensemble_id', 'cutting_id', 'element_id'),)
+
--- a/web/ldt/ldt/templates/admin/ldt/app_action.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/admin/ldt/app_action.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,11 +1,7 @@
-{% extends "admin/base_site.html" %}
-{% load i18n %} 
+{% extends "admin/base_site.html" %} {% load i18n %} {% block
+breadcrumbs %}
+<div class="breadcrumbs"><a href="{% url admin:index %}"> {%
+trans "Home" %}</a> &rsaquo; <a href="{% url admin:app_list 'ldt' %}">
+ldt</a> &rsaquo; {{ current_action }}</div>
+{% endblock %}
 
-{% block breadcrumbs %}
-<div class="breadcrumbs"><a href="{% url admin:index %}">
-{% trans "Home" %}</a> &rsaquo; 
-<a href="{% url admin:app_list 'ldt' %}">
-ldt</a> &rsaquo;
-{{ current_action }}
-</div>{% endblock %}
-
--- a/web/ldt/ldt/templates/admin/ldt/app_index.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/admin/ldt/app_index.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,30 +1,25 @@
-{% extends "admin/app_index.html" %}
-{% load i18n %}
-
-{% block content %}
+{% extends "admin/app_index.html" %} {% load i18n %} {% block content %}
 {{ block.super }}
 
-        <div class="module">
-            <table summary="Import">
-                <caption>Import</caption>
-                <tr>
-                    <th>            
-                        <a href="{{WEB_URL}}{% url admin:ldt_content_import_file %}">Import an ldt</a>
-                    </th>
-                    <td>&nbsp;</td>
-                <!--tr>
+<div class="module">
+<table summary="Import">
+	<caption>Import</caption>
+	<tr>
+		<th><a href="{{WEB_URL}}{% url admin:ldt_content_import_file %}">Import
+		an ldt</a></th>
+		<td>&nbsp;</td>
+		<!--tr>
                     <th>            
                         <a href="content/export/form">Generate ldt</a>
                     </th>
                     <td>&nbsp;</td>
                 </tr-->
-                <tr>
-                    <th>            
-                        <a href="{{WEB_URL}}{% url admin:ldt_content_reindex %}">Reindex</a>
-                    </th>
-                    <td>&nbsp;</td>         
-                </tr>
-            </table>
-        </div>
+		<tr>
+			<th><a href="{{WEB_URL}}{% url admin:ldt_content_reindex %}">Reindex</a>
+			</th>
+			<td>&nbsp;</td>
+		</tr>
+</table>
+</div>
 
 {% endblock %}
--- a/web/ldt/ldt/templates/admin/ldt/content/reindex_form.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/admin/ldt/content/reindex_form.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,30 +1,22 @@
-{% extends "admin/ldt/app_action.html" %}
-{% load i18n %} 
-{# reindex contents #}
-
-{% block content %}
-
-{% if message %}
+{% extends "admin/ldt/app_action.html" %} {% load i18n %} {# reindex
+contents #} {% block content %} {% if message %}
 <div>
-<p>
-{{ message }}
-</p>
+<p>{{ message }}</p>
 </div>
-{% endif %}
-{% if form. %}
-<div>
-</div>
+{% endif %} {% if form. %}
+<div></div>
 {% endif %}
 <div>
-<form method="post" action="{{WEB_URL}}{% url admin:ldt_content_reindex %}">
-    {% csrf_token %}
-	<table>
+<form method="post"
+	action="{{WEB_URL}}{% url admin:ldt_content_reindex %}">{%
+csrf_token %}
+<table>
 	{{ form.as_table }}
-	</table>
-	<input type="submit"/>
-</form>
+</table>
+<input type="submit" /></form>
 </div>
 
-<a href="{{WEB_URL}}{% url admin:app_list 'ldt' %}" >Back to administration page</a>
+<a href="{{WEB_URL}}{% url admin:app_list 'ldt' %}">Back to
+administration page</a>
 
 {% endblock %}
--- a/web/ldt/ldt/templates/admin/ldt/content/search_form.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/admin/ldt/content/search_form.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,14 +1,13 @@
-{% extends "base.html" %}
-
-{% block content %}
-
-<form method="post" action="{{WEB_URL}}{% url ldt.ldt.views.searchIndex %}" accept-charset="utf-8">
+{% extends "base.html" %} {% block content %}
 
-	<table>
+<form method="post"
+	action="{{WEB_URL}}{% url ldt.ldt.views.searchIndex %}"
+	accept-charset="utf-8">
+
+<table>
 	{{ form.as_table }}
-	</table>
-	<input type="submit"/>
-</form>
+</table>
+<input type="submit" /></form>
 
 
 {% endblock %}
--- a/web/ldt/ldt/templates/admin/ldt/content/upload_form.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/admin/ldt/content/upload_form.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,28 +1,26 @@
-{% extends "admin/ldt/app_action.html" %}
-{# import an ldt #}
-{% block content %}
-<p>Vous pouvez importer un fichier ldt ou un zip qui compresse un fichier .ldt et plusieurs fichiers .iri. </p>
-<p>Bien verifiez vous que le chemin de source est absolute pour un fichier ldt lors qu'il est tout seul, alors qu'il est relatif s'il est dans le zip</p>
+{% extends "admin/ldt/app_action.html" %} {# import an ldt #} {% block
+content %}
+<p>Vous pouvez importer un fichier ldt ou un zip qui compresse un
+fichier .ldt et plusieurs fichiers .iri.</p>
+<p>Bien verifiez vous que le chemin de source est absolute pour un
+fichier ldt lors qu'il est tout seul, alors qu'il est relatif s'il est
+dans le zip</p>
 <p>Vous pouvez indiquer le chemin de video si vous avez besoin</p>
 {% if message %}
 <div>
-<p>
-{{ message }}
-</p>
+<p>{{ message }}</p>
 </div>
+{% endif %} {% if form %}
+
+<form method="post" enctype="multipart/form-data" action="">{%
+csrf_token %}
+<table>
+	{{ form.as_table }}
+</table>
+<input type="submit" /></form>
 {% endif %}
 
-{% if form %}
-
-<form method="post" enctype="multipart/form-data" action="">
-    {% csrf_token %}
-	<table>
-	{{ form.as_table }}
-	</table>
-	<input type="submit"/>
-</form>
-{% endif %}
-
-<a href="{% url admin:app_list 'ldt' %}" >Back to administration page</a>
+<a href="{% url admin:app_list 'ldt' %}">Back to administration
+page</a>
 
 {% endblock %}
--- a/web/ldt/ldt/templates/iriuser/ldt/copy_ldt.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/copy_ldt.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,5 +1,4 @@
-{% load i18n %}
-{# form of copy of project ldt #}
+{% load i18n %} {# form of copy of project ldt #}
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <?xml version="1.0" encoding="UTF-8"?>
@@ -9,14 +8,11 @@
 </head>
 <body>
 <div id="add_contribution">
- <div class="title">{% trans "Copy your project" %}</div>
-    <form action="" method="POST">        
-        {% csrf_token %}
-        <label for="title">{% trans "Title" %}:</label>
-        <input class= "inputbox required" type="text" name="title" size="80"; value="" id="title" />
-        
-    <input class="button" id="ldt_submit" type="submit" value="{% trans 'Copy' %}"/>
-    </form>
+<div class="title">{% trans "Copy your project" %}</div>
+<form action="" method="POST">{% csrf_token %} <label for="title">{%
+trans "Title" %}:</label> <input class="inputbox required" type="text"
+	name="title" size="80" ; value="" id="title" /> <input class="button"
+	id="ldt_submit" type="submit" value="{% trans 'Copy' %}" /></form>
 </div>
 </body>
 </html>
--- a/web/ldt/ldt/templates/iriuser/ldt/create_ldt.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/create_ldt.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,5 +1,4 @@
-{% load i18n %}
-{# form of creation of project ldt #}
+{% load i18n %} {# form of creation of project ldt #}
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <?xml version="1.0" encoding="UTF-8"?>
@@ -9,21 +8,22 @@
 </head>
 <body>
 <div id="add_contribution">
- <div class="title">{% trans "Create your project" %}</div>
-    <form action="{{create_project_action}}" method="POST">        
-        {% csrf_token %}
-        <label for="title">{% trans "Title" %}:</label>
-        <input class= "inputbox required" type="text" name="title" size="80"; value="" id="title" />
-        
-        <div class="title">{% trans "List of contents" %}</div>
-            <ul class='contentlist'>
-                {% for content in contents %}
-                <li><input type="checkbox" name="contents" value="{{ content.id}}" checked="true"/>{{content.iri_id}}</li>
-                {% endfor %}
-            </ul>
-        
-    <input class="button" id="ldt_submit" type="submit" value="{% trans 'Create' %}"/>
-    </form>
+<div class="title">{% trans "Create your project" %}</div>
+<form action="{{create_project_action}}" method="POST">{%
+csrf_token %} <label for="title">{% trans "Title" %}:</label> <input
+	class="inputbox required" type="text" name="title" size="80" ; value=""
+	id="title" />
+
+<div class="title">{% trans "List of contents" %}</div>
+<ul class='contentlist'>
+	{% for content in contents %}
+	<li><input type="checkbox" name="contents" value="{{ content.id}}"
+		checked="true" />{{content.iri_id}}</li>
+	{% endfor %}
+</ul>
+
+<input class="button" id="ldt_submit" type="submit"
+	value="{% trans 'Create' %}" /></form>
 </div>
 </body>
 </html>
--- a/web/ldt/ldt/templates/iriuser/ldt/init_ldt.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/init_ldt.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,22 +1,21 @@
 <html>
-  <head>
-	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-	<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
-	<meta http-equiv="Pragma" content="no-cache" />
-	<meta http-equiv="Cache" content="no store" />
-	<meta http-equiv="Expires" content="-1" />
-	<title>Ligne de Temps - IRI</title>
-	<script type="text/javascript" src="{{MEDIA_URL}}js/swfobject.js"></script>
-	<script type="text/javascript">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
+<meta http-equiv="Pragma" content="no-cache" />
+<meta http-equiv="Cache" content="no store" />
+<meta http-equiv="Expires" content="-1" />
+<title>Ligne de Temps - IRI</title>
+<script type="text/javascript" src="{{MEDIA_URL}}js/swfobject.js"></script>
+<script type="text/javascript">
 	    
 	</script>
-  </head>
+</head>
 
 <body id="init_ldt_view">
 
-  <div id="ldtInit" style="width:1001px;height:631px;">&nbsp;
-  </div>
-  <script language="JavaScript" type="text/javascript">
+<div id="ldtInit" style="width: 1001px; height: 631px;">&nbsp;</div>
+<script language="JavaScript" type="text/javascript">
 
         var params = {
             quality:"high",
--- a/web/ldt/ldt/templates/iriuser/ldt/ldt_list.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/ldt_list.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,8 +1,7 @@
-{% extends "ldt/user/user_base.html" %}
-{# list of projects ldt #}
-{% load i18n %}
-{% block js_import %}{{ block.super }}
-<script type="text/javascript" src="{{ BASE_URL }}static/js/jquery.DOMwindow.js"></script>
+{% extends "ldt/user/user_base.html" %} {# list of projects ldt #} {%
+load i18n %} {% block js_import %}{{ block.super }}
+<script type="text/javascript"
+	src="{{ BASE_URL }}static/js/jquery.DOMwindow.js"></script>
 <script type="text/javascript">           
         $(document).ready(function(){
         	$('.ldt_link').nyroModal({
@@ -39,43 +38,43 @@
             	});       
         });        	        
 </script>
-{% endblock %}
-{% block css_import %}
-{{ block.super }}
-<link rel="stylesheet" type="text/css" href="{{ BASE_URL }}static/ldt/css/ldt.css" />
-{% endblock %}
-
-{% block breadcrumb %}
-    <li></li>
-    <li><a href="{% url ldt.userpanel.views.space %}">{% trans "Space" %}</a></li>
-    <li>{% trans "Ldt Project" %}</li>  
-{% endblock %}
-{% block content_title %}{% trans "Ldt Project" %}{% endblock %}
-
-{% block iricontent %}
-<div id='ldtlist'>
-<a href="{% url ldt.ldt.views.create_ldt_view %}" class="create_ldt_link">{% trans 'Create new project'%}</a>
-    <table>
-    <caption>{% trans "Project" %}</caption>
-    <thead>
-        <tr>
-        <th width="170">{% trans "title" %}</th>
-        <th width="20">{% trans " published" %}</th>
-        </tr>
-    </thead>
-    <tbody>
-        {% for ldt in ldtProjects %}    
-        <tr>
-        <th><a href="{% url ldt.ldt.views.indexProject ldt.ldt_id %}" class="ldt_link">{{ ldt.title  }}</a></th>
-        {% ifequal ldt.state 2%}
-        <td><a href ="{% url ldt.ldt.views.unpublish ldt.ldt_id%}"><img alt="True" src="{{BASE_URL}}static/admin/img/admin/icon-yes.gif"/></td>
-        {% else %}
-        <td><a href="{% url ldt.ldt.views.publish ldt.ldt_id %}"><img alt="False" src="{{BASE_URL}}static/admin/img/admin/icon-no.gif"/></td>
-        {% endifequal %}
-        </tr>
-        {% endfor %}
-    </tbody>
-    </table>
+{% endblock %} {% block css_import %} {{ block.super }}
+<link rel="stylesheet" type="text/css"
+	href="{{ BASE_URL }}static/ldt/css/ldt.css" />
+{% endblock %} {% block breadcrumb %}
+<li></li>
+<li><a href="{% url ldt.userpanel.views.space %}">{% trans
+"Space" %}</a></li>
+<li>{% trans "Ldt Project" %}</li>
+{% endblock %} {% block content_title %}{% trans "Ldt Project" %}{%
+endblock %} {% block iricontent %}
+<div id='ldtlist'><a
+	href="{% url ldt.ldt.views.create_ldt_view %}" class="create_ldt_link">{%
+trans 'Create new project'%}</a>
+<table>
+	<caption>{% trans "Project" %}</caption>
+	<thead>
+		<tr>
+			<th width="170">{% trans "title" %}</th>
+			<th width="20">{% trans " published" %}</th>
+		</tr>
+	</thead>
+	<tbody>
+		{% for ldt in ldtProjects %}
+		<tr>
+			<th><a href="{% url ldt.ldt.views.indexProject ldt.ldt_id %}"
+				class="ldt_link">{{ ldt.title }}</a></th>
+			{% ifequal ldt.state 2%}
+			<td><a href="{% url ldt.ldt.views.unpublish ldt.ldt_id%}"><img
+				alt="True" src="{{BASE_URL}}static/admin/img/admin/icon-yes.gif" /></td>
+			{% else %}
+			<td><a href="{% url ldt.ldt.views.publish ldt.ldt_id %}"><img
+				alt="False" src="{{BASE_URL}}static/admin/img/admin/icon-no.gif" /></td>
+			{% endifequal %}
+		</tr>
+		{% endfor %}
+	</tbody>
+</table>
 </div>
 {% endblock %}
 
--- a/web/ldt/ldt/templates/iriuser/ldt/loading.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/loading.html	Tue Jun 08 15:10:46 2010 +0200
@@ -4,24 +4,23 @@
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
 <style type="text/css">
-    
-    .center{
-        position: absolute;
-        top: 50%;
-        left: 50%;
-    }
-    .center div{
-        position:relative;
-        top: -7px;
-        left: -104px;
-    }
+.center {
+	position: absolute;
+	top: 50%;
+	left: 50%;
+}
+
+.center div {
+	position: relative;
+	top: -7px;
+	left: -104px;
+}
 </style>
 </head>
 <body>
 <div class="center">
-<div>
-<img alt="loading" src="{{MEDIA_URL}}img/loadingAnimation.gif" />
-</div>
+<div><img alt="loading"
+	src="{{MEDIA_URL}}img/loadingAnimation.gif" /></div>
 </div>
 </body>
 </html>
--- a/web/ldt/ldt/templates/iriuser/ldt/save_done.html	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/templates/iriuser/ldt/save_done.html	Tue Jun 08 15:10:46 2010 +0200
@@ -1,4 +1,5 @@
 <p>done</p>
-<p>{{ldt}}<p>
+<p>{{ldt}}
+<p>
 <p>{{id}}</p>
 <p>title:{{title}}</p>
\ No newline at end of file
--- a/web/ldt/ldt/utils.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/ldt/utils.py	Tue Jun 08 15:10:46 2010 +0200
@@ -17,15 +17,16 @@
 
     def query(self, field, query):
         indexSearcher = lucene.IndexSearcher(STORE)
-        queryParser = lucene.QueryParser(field, lucene.FrenchAnalyzer())
+        queryParser = lucene.QueryParser(lucene.Version.LUCENE_30, field, lucene.FrenchAnalyzer(lucene.Version.LUCENE_30))
         queryParser.setDefaultOperator(lucene.QueryParser.Operator.AND)
         queryObj = queryParser.parse(query)
-        hits = indexSearcher.search(queryObj)
+        hits = indexSearcher.search(queryObj, settings.LDT_MAX_SEARCH_NUMBER)
 	
         res = []
-        for hit in hits:
-            doc = lucene.Hit.cast_(hit).getDocument()
-        res.append({"iri_id":doc.get("iri_id"),"ensemble_id":doc.get("ensemble_id"),"decoupage_id":doc.get("decoupage_id"), "element_id":doc.get("element_id")})
+        for hit in hits.scoreDocs:
+            doc = indexSearcher.doc(hit.doc)
+            res.append({"iri_id":doc.get("iri_id"),"ensemble_id":doc.get("ensemble_id"),"decoupage_id":doc.get("decoupage_id"), "element_id":doc.get("element_id")})
+        indexSearcher.close()
         return res
 
     def queryAll(self, query):		
--- a/web/ldt/settings.py	Tue Jun 08 13:39:41 2010 +0200
+++ b/web/ldt/settings.py	Tue Jun 08 15:10:46 2010 +0200
@@ -26,6 +26,7 @@
 
 ACCOUNT_ACTIVATION_DAYS =  getattr(settings, 'ACCOUNT_ACTIVATION_DAYS', 7)
 LDT_MEDIA_PREFIX =  getattr(settings, 'LDT_MEDIA_PREFIX', MEDIA_URL + 'ldt/')
+LDT_MAX_SEARCH_NUMBER = 50