aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jm2l/models.py12
-rw-r--r--jm2l/templates/index.mako4
-rw-r--r--jm2l/templates/index_profil.mako4
-rw-r--r--jm2l/views.py13
-rw-r--r--setup.py5
5 files changed, 19 insertions, 19 deletions
diff --git a/jm2l/models.py b/jm2l/models.py
index 9e33644..0bc212c 100644
--- a/jm2l/models.py
+++ b/jm2l/models.py
@@ -19,9 +19,9 @@ from sqlalchemy import (
)
from slugify import slugify
-from webhelpers.text import urlify
-from webhelpers.paginate import PageURL_WebOb, Page
-from webhelpers.date import time_ago_in_words
+from webhelpers2.text import urlify
+from webhelpers2.date import time_ago_in_words
+from paginate import Page
from collections import namedtuple
@@ -587,7 +587,7 @@ class Entry(Base):
@classmethod
def all(cls):
- return DBSession.query(Entry).order_by(sa.desc(Entry.created))
+ return DBSession.query(Entry).order_by(sa.desc(Entry.created)).all()
@classmethod
def by_id(cls, id):
@@ -603,8 +603,8 @@ class Entry(Base):
@classmethod
def get_paginator(cls, request, page=1):
- page_url = PageURL_WebOb(request)
- return Page(Entry.all(), page, url=page_url, items_per_page=5)
+ return Page(Entry.all(), page, items_per_page=5,
+ url_maker=lambda p: "%s?page=%s" % (request.application_url, p))
#class Seances(Base):
# __tablename__ = 'seances'
diff --git a/jm2l/templates/index.mako b/jm2l/templates/index.mako
index fb53150..7b24413 100644
--- a/jm2l/templates/index.mako
+++ b/jm2l/templates/index.mako
@@ -21,7 +21,7 @@ ${vars(user_id)}
% if paginator.items:
- ${paginator.pager()}
+ ${paginator.pager() | n}
<h2>Blog entries</h2>
@@ -34,7 +34,7 @@ ${vars(user_id)}
% endfor
</ul>
- ${paginator.pager()}
+ ${paginator.pager() | n}
% else:
diff --git a/jm2l/templates/index_profil.mako b/jm2l/templates/index_profil.mako
index 87667a4..ec12831 100644
--- a/jm2l/templates/index_profil.mako
+++ b/jm2l/templates/index_profil.mako
@@ -102,7 +102,7 @@ user_id = authenticated_userid(request)
% if paginator.items:
- ${paginator.pager()}
+ ${paginator.pager() | n}
<h2>Blog entries</h2>
@@ -115,7 +115,7 @@ user_id = authenticated_userid(request)
% endfor
</ul>
- ${paginator.pager()}
+ ${paginator.pager() | n}
% else:
diff --git a/jm2l/views.py b/jm2l/views.py
index e3485ae..f5dc1b3 100644
--- a/jm2l/views.py
+++ b/jm2l/views.py
@@ -6,6 +6,7 @@ from pyramid.response import Response
from pyramid.view import notfound_view_config, forbidden_view_config
from pyramid.view import view_config
from pyramid_mailer import get_mailer
+from pyramid_mailer.message import Attachment, Message
from mako.template import Template
# Import Web Forms
from .forms import *
@@ -18,10 +19,8 @@ from slugify import slugify
from icalendar import Calendar
from pytz import timezone
from icalendar import Event as Evt
-from pyramid_mailer import get_mailer
-from pyramid_mailer.message import Attachment, Message
# Then, standard libs
-import webhelpers.paginate as paginate
+import paginate
import unicodedata
import time
import datetime
@@ -87,8 +86,8 @@ def JSON_User_Request(request):
# Query database
Users = DBSession.query(User.uid, User.nom, User.prenom)\
.filter(User.slug.contains( remove_accents(UserQuery) ))
- page_url = paginate.PageURL_WebOb(request)
- records = paginate.Page(Users, current_page, url=page_url, items_per_page=pageSize)
+ records = paginate.Page(Users, current_page, items_per_page=pageSize,
+ url_maker=lambda p: "%s?page=%s" % (request.application_url, p))
ListMatchUser = map( lambda u:{"id": u.uid, "text":"%s %s" % ( u.prenom, u.nom )}, records )
return { "Results": ListMatchUser, "Total":records.item_count,
"logged_in":request.authenticated_userid }
@@ -112,8 +111,8 @@ def JSON_Tiers_Request(request):
# Query database
JTiers = DBSession.query(Tiers.uid, Tiers.name)\
.filter(Tiers.slug.contains( remove_accents(TiersQuery) ))
- page_url = paginate.PageURL_WebOb(request)
- records = paginate.Page(JTiers, current_page, url=page_url, items_per_page=pageSize)
+ records = paginate.Page(JTiers, current_page, items_per_page=pageSize,
+ url_maker=lambda p: "%s?page=%s" % (request.application_url, p))
ListMatchTiers = map( lambda t:{"id": t.uid, "text": t.name }, records )
return { "Results": ListMatchTiers, "Total":records.item_count,
"logged_in":request.authenticated_userid }
diff --git a/setup.py b/setup.py
index 888b92f..6b8dc7e 100644
--- a/setup.py
+++ b/setup.py
@@ -21,7 +21,7 @@ requires = [
'zope.sqlalchemy',
'waitress',
'wtforms',
- 'webhelpers',
+ 'webhelpers2',
'lxml',
'python-slugify',
'icalendar',
@@ -29,7 +29,8 @@ requires = [
'Pillow',
'pyramid_exclog',
'repoze.sendmail==4.1',
- 'pyramid_mailer'
+ 'pyramid_mailer',
+ 'paginate'
]
setup(name='JM2L',