--- a/web/ldt/ldt_utils/__init__.py Mon Nov 15 18:56:22 2010 +0100
+++ b/web/ldt/ldt_utils/__init__.py Tue Nov 16 11:57:22 2010 +0100
@@ -11,5 +11,5 @@
ANALYZER.addAnalyzer("all",lucene.FrenchAnalyzer(lucene.Version.LUCENE_CURRENT))
-VERSION = (0,1)
-VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION)))
+VERSION = (1,0)
+VERSION_STR = unicode(".".join(map(lambda i:"%01d" % (i,), VERSION)))
--- a/web/ldt/ldt_utils/tests.py Mon Nov 15 18:56:22 2010 +0100
+++ b/web/ldt/ldt_utils/tests.py Tue Nov 16 11:57:22 2010 +0100
@@ -15,6 +15,7 @@
from django.contrib.auth.models import *
from django.conf import settings
from django.test.client import Client
+from ldt.ldt_utils import VERSION_STR
@@ -33,7 +34,7 @@
annot.delete()
def test_create_annotation(self):
- response = self.c.post('/ldt/create/', {'content':self.content})
+ response = self.c.post('/api/'+ VERSION_STR +'/text/create/', {'content':self.content})
self.annot1 = lxml.etree.fromstring(response.content)
self.assertEqual(self.annot1.xpath("/iri/text-annotation/id/text()")[0],"f2c1d1fa-629d-4520-a3d2-955b4f2582c0")
self.assertEqual(self.annot1.xpath("/iri/text-annotation/content")[0].tag,"content")
@@ -45,7 +46,7 @@
# def test_error_create(self):
# content = base64.urlsafe_b64encode('<iri><text-annotation><id>d2c1d1fa-629d-4520-a3d2-955b4f2582c0</id><uri>http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168</uri><tags><tag>tag1</tag><tag>tag2</tag></tags><content><color>#AAAAAA</color><description><![CDATA[texte de description]]></description><title><![CDATA[titre de l\'annotation]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>79cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created>2010-09-06 12:33:53.417550</created><creator>oaubert</creator><creator-id>79cd0532-1dda-4130-b351-6a181130a7c9</creator-id><modified>2010-09-06 12:33:53.420459</modified></meta></text-annotation></iri>')
-# response = self.c.post('/ldt/create/', {'content':content})
+# response = self.c.post('/api/'+ VERSION_STR +'/text/create/', {'content':content})
# #annot2 = create_annotation(content)
# self.assertEqual(response.status_code, '409')
@@ -62,7 +63,7 @@
annot.delete()
def test_get_annotation(self):
- response = self.c.get('/ldt/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
+ response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
self.annot1 = lxml.etree.fromstring(response.content)
#self.annot1 = get_annotation("d2c1d1fa-629d-4520-a3d2-955b4f2582c0")
self.assertEqual(self.annot1.xpath("/iri/text-annotation/id/text()")[0],self.annotation.id)
@@ -71,8 +72,8 @@
#self.assertEqual(self.annot1.xpath("/iri/text-annotation/meta/created/text()"), self.annotation.creation_date)
# def test_error_get(self):
-# response = self.c.get('/ldt/get/', {'id':'2'})
-# #response = self.c.get('/ldt/get/', {'id':'2'})
+# response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'2'})
+# #response = self.c.get('/api/'+ VERSION_STR +'/text/get/', {'id':'2'})
# #annot3 = get_annotation('d2c1d1fa-629d-4520-a3d2-955b4f2582c0')
# #resp = response.status_code
# self.assertEqual(response.status_code,'404')
@@ -96,7 +97,7 @@
user = 'wakimd'
uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
limit= 1
- response = self.c.get('/ldt/filter/', {'uri':uri,'creator':user,'limit':limit})
+ response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri,'creator':user,'limit':limit})
doc = lxml.etree.fromstring(response.content)
#doc = filter_annotation(uri,None,limit,user)
cpt = 0
@@ -111,7 +112,7 @@
def test_filter_annotation_uri(self):
uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
- response = self.c.get('/ldt/filter/', {'uri':uri})
+ response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri})
doc = lxml.etree.fromstring(response.content)
#doc = filter_annotation(uri,None,limit,None)
for elem in doc.xpath("/iri/text-annotation/uri/text()"):
@@ -121,7 +122,7 @@
uri = "http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168"
filter = 'lors'
limit = None
- response = self.c.get('/ldt/filter/', {'uri':uri,'filter':'lors'})
+ response = self.c.get('/api/'+ VERSION_STR +'/text/filter/', {'uri':uri,'filter':'lors'})
doc = lxml.etree.fromstring(response.content)
#doc = filter_annotation(uri,filter,limit,user)
for elem in doc.xpath("/iri/text-annotation/content/text/text()"):
@@ -144,7 +145,7 @@
annot.delete()
def test_delete_annotation(self):
- response = self.c.post('/ldt/delete/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
+ response = self.c.post('/api/'+ VERSION_STR +'/text/delete/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
#response2 = self.c.get('/ldt/get/', {'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
doc = lxml.etree.fromstring(response.content)
#doc=delete_annotation("d2c1d1fa-629d-4520-a3d2-955b4f2582c0")
@@ -155,7 +156,7 @@
#self.assertEqual(response2.status_code, '404')
# def test_error_delete(self):
-# response = self.c.post('/ldt/delete/', {'id':'1'})
+# response = self.c.post('/api/'+ VERSION_STR +'/text/ldt/delete/', {'id':'1'})
# #annot4 = delete_annotation('f2c1d1fa-629d-4520-a3d2-955b4f2582c0')
# self.assertEqual(response.status_code,'404')
@@ -173,7 +174,7 @@
def test_update_annotation(self):
content = base64.urlsafe_b64encode('<iri><text-annotation><id></id><uri></uri><tags><tag>tag1</tag><tag>tag2new</tag><tag>tag3</tag></tags><content><color>#DDDDDD</color><description><![CDATA[texte de description update]]></description><title></title><text><![CDATA[texte selectionne a nouveau lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>80cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created></created><creator></creator><creator-id></creator-id><modified>2010-11-06 12:33:53.420459</modified></meta></text-annotation></iri>')
- response = self.c.post('/ldt/update/', {'content':content,'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
+ response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'d2c1d1fa-629d-4520-a3d2-955b4f2582c0'})
doc = lxml.etree.fromstring(response.content)
#doc = update_annotation(content,'d2c1d1fa-629d-4520-a3d2-955b4f2582c0')
self.assertEqual(doc.xpath("/iri/text-annotation/id/text()")[0],"d2c1d1fa-629d-4520-a3d2-955b4f2582c0")
@@ -182,7 +183,7 @@
# def test_error_update(self):
# content = base64.urlsafe_b64encode('<iri><text-annotation><id>d2c1d1fa-629d-4520-a3d2-955b4f2582c0</id><uri>http://www.leezam.com/pub/epub/123456!/OPS/chapter2.xhtml#pos=56,168</uri><tags><tag>tag1</tag><tag>tag2</tag></tags><content><color>#AAAAAA</color><description><![CDATA[texte de description]]></description><title><![CDATA[titre de l\'annotation]]></title><text><![CDATA[texte selectionne lors de la creation de l\'annotation]]></text></content><meta><contributor>oaubert</contributor><contributor-id>79cd0532-1dda-4130-b351-6a181130a7c9</contributor-id><created>2010-09-06 12:33:53.417550</created><creator>oaubert</creator><creator-id>79cd0532-1dda-4130-b351-6a181130a7c9</creator-id><modified>2010-09-06 12:33:53.420459</modified></meta></text-annotation></iri>')
-# response = self.c.post('/update/', {'content':content,'id':'1'})
+# response = self.c.post('/api/'+ VERSION_STR +'/text/update/', {'content':content,'id':'1'})
# #annot5=update_annotation()
# self.assertEqual(response.status_code,'404')
#
--- a/web/leezam/urls.py Mon Nov 15 18:56:22 2010 +0100
+++ b/web/leezam/urls.py Tue Nov 16 11:57:22 2010 +0100
@@ -1,6 +1,6 @@
from django.conf.urls.defaults import patterns ,include, url
from django.contrib import admin
-
+from ldt.ldt_utils import VERSION_STR
# Uncomment the next two lines to enable the admin:
admin.autodiscover()
@@ -17,10 +17,10 @@
(r'^admin/', include(admin.site.urls)),
(r'^i18n/', include('django.conf.urls.i18n')),
- (r'^ldt/', include('ldt.ldt_utils.urls')),
+ (r'^api/' + VERSION_STR + '/text/', include('ldt.ldt_utils.urls')),
(r'^user/', include('ldt.user.urls')),
(r'^accounts/', include('registration.backends.simple.urls')),
- (r'^/?$', 'django.views.generic.simple.redirect_to', {'url': 'ldt'}),
+ (r'^/?$', 'django.views.generic.simple.redirect_to', {'url': 'api'}),
)