Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

96 lines (74 sloc) 3.73 kB
Prepare proper documentation and examples for GitHub/readthedocs
Prepare a method that can be overriden for extension modules like paginate-sqlalchemy
(e.g. get_wrapper)
Move SQLAlchemy code into a separate module paginate-sqlalchemy and subclass paginate.Page() for that purpose.
Upload to PyPi
Announce to pylons-discussion mailing list.
Add AJAX tutorial
onclick (optional)
This paramter is a string containing optional Javascript code
that will be used as the 'onclick' action of each pager link.
It can be used to enhance your pager with AJAX actions loading another
page into a DOM object.
In this string the variable '$partial_url' will be replaced by
the URL linking to the desired page with an added 'partial=1'
parameter (or whatever you set 'partial_param' to).
In addition the '$page' variable gets replaced by the
respective page number.
Note that the URL to the destination page contains a 'partial_param'
parameter so that you can distinguish between AJAX requests (just
refreshing the paginated area of your page) and full requests (loading
the whole new page).
[Backward compatibility: you can use '%s' instead of '$partial_url']
jQuery example:
"$('#my-page-area').load('$partial_url'); return false;"
Yahoo UI example:
"YAHOO.util.Connect.asyncRequest('GET','$partial_url',{
success:function(o){YAHOO.util.Dom.get('#my-page-area').innerHTML=o.responseText;}
},null); return false;"
scriptaculous example:
"new Ajax.Updater('#my-page-area', '$partial_url',
{asynchronous:true, evalScripts:true}); return false;"
ExtJS example:
"Ext.get('#my-page-area').load({url:'$partial_url'}); return false;"
Custom example:
"my_load_page($page)"
p.pager(url="/index.php?page=$page", link_attr=dict(onclick="$('target').load('/ding/dong?page=$page'"))
Write SQLAlchemy tests
Create test with setup/teardown code for paginate.sqlalchemy.SqlalchemyPage (e.g. sqlite)
#class TestSQLAlchemyCollectionTypes(unittest.TestCase):
# def setUp(self):
# try:
# import sqlalchemy as sa
# import sqlalchemy.orm as orm
# except ImportError:
# raise SkipTest()
# self.engine = engine = sa.create_engine("sqlite://") # Memory database
# self.sessionmaker = orm.sessionmaker(bind=engine)
# self.metadata = metadata = sa.MetaData(bind=engine)
# self.notes = notes = sa.Table("Notes", metadata,
# sa.Column("id", sa.Integer, primary_key=True))
# class Note(object):
# pass
# self.Note = Note
# notes.create()
# orm.mapper(Note, notes)
# insert = notes.insert()
# records = [{"id": x} for x in range(1, 101)]
# engine.execute(insert, records)
#
# def tearDown(self):
# import sqlalchemy as sa
# import sqlalchemy.orm as orm
# orm.clear_mappers()
# self.notes.drop()
#
# def test_sqlalchemy_orm(self):
# session = self.sessionmaker()
# q = session.query(self.Note).order_by(self.Note.id)
# page = paginate.Page(q)
# records = list(page)
# eq_(records[0].id, 1)
# eq_(records[-1].id, 20)
add support for CouchDB databases (http://guide.couchdb.org/editions/1/de/recipes.html)
careful: CouchDB is stupid and has very limited and weird behavior when it comes to choosing a certain page of data
Jump to Line
Something went wrong with that request. Please try again.