error from sqlalchemy while using dojo in moviedemo

31 views
Skip to first unread message

alind sharma

unread,
Feb 2, 2012, 8:27:44 AM2/2/12
to turbo...@googlegroups.com
I am getting this error while using dojo for move demo


TypeError: Sorry, your collection type is not supported by the paginate module. You can provide a list, a tuple, a SQLAlchemy " "select object or a SQLAlchemy ORM-query object.


=========Here is the model=====

# -*- coding: utf-8 -*-
"""Sample model module."""

from sqlalchemy import *
from sqlalchemy.orm import mapper, relation
from sqlalchemy import Table, ForeignKey, Column
from sqlalchemy.types import Integer, Unicode
#from sqlalchemy.orm import relation, backref
from moviedemo.model import DeclarativeBase, metadata, DBSession
from sqlalchemy.orm import relation

from moviedemo.model import DeclarativeBase, metadata

class Movie(DeclarativeBase):
    __tablename__ = "movies"
    movie_id = Column(Integer, primary_key=True)
    #title = Column(String(100), nullable=False)
    description = Column(Text, nullable=True)
    #release_date = Column(Date, nullable=True)

=== HEre is thecontroller ====

# -*- coding: utf-8 -*-
"""Main Controller"""

from formencode.validators import Int, NotEmpty, DateConverter, DateValidator
from moviedemo import model
from moviedemo.controllers.error import ErrorController
from moviedemo.controllers.secure import SecureController
from moviedemo.lib.base import BaseController
from moviedemo.model import DBSession, Movie
from moviedemo.model import DBSession, metadata
from repoze.what import predicates

from sprox.dojo.fillerbase import DojoTableFiller as TableFiller
#from sprox.fillerbase import TableFiller

from sprox.dojo.tablebase import DojoTableBase as TableBase
#from sprox.tablebase import TableBase

#from sprox.fillerbase import EditFormFiller

from sprox.dojo.formbase import DojoAddRecordForm as AddRecordForm
#from sprox.formbase import AddRecordForm

from sprox.dojo.formbase import DojoEditableForm as EditableForm
#from sprox.formbase import EditableForm

from tg import expose, flash, require, url, request, redirect, validate
from tg import tmpl_context, request
from tg.i18n import ugettext as _, lazy_ugettext as l_
from tgext.admin.controller import AdminController
from tgext.admin.tgadminconfig import TGAdminConfig
from tgext.crud import CrudRestController
from tw.core import WidgetsList
from tw.forms import TableForm, TextField, CalendarDatePicker, SingleSelectField, TextArea
__all__ = ['RootController']

class DeclarativeMovieController(CrudRestController):
    model = Movie

#    class new_form_type(AddRecordForm):
#        __model__ = Movie
#        __omit_fields__ = ['genre_id', 'movie_id']
#
#    class edit_form_type(EditableForm):
#        __model__ = Movie
#        __omit_fields__ = ['genre_id', 'movie_id']
#
#    class edit_filler_type(EditFormFiller):
#        __model__ = Movie

    class table_type(TableBase):
        __model__ = Movie
        __omit_fields__ = ['genre_id', 'movie_id']

    class table_filler_type(TableFiller):
        __model__ = Movie

class RootController(BaseController):
    """
    The root controller for the moviedemo application.

    All the other controllers and WSGI applications should be mounted on this
    controller. For example::

        panel = ControlPanelController()
        another_app = AnotherWSGIApplication()

    Keep in mind that WSGI applications shouldn't be mounted directly: They
    must be wrapped around with :class:`tg.controllers.WSGIAppController`.

    """
    secc = SecureController()
    admin = AdminController(model, DBSession, config_type=TGAdminConfig)

    error = ErrorController()
    movie = DeclarativeMovieController(DBSession)

    @expose('moviedemo.templates.index')
    def index(self):
        """Handle the front-page."""
        return dict(page='index')

    @expose('moviedemo.templates.about')
    def about(self):
        """Handle the 'about' page."""
        return dict(page='about')

    @expose('moviedemo.templates.environ')
    def environ(self):
        """This method showcases TG's access to the wsgi environment."""
        return dict(environment=request.environ)

    @expose('moviedemo.templates.data')
    @expose('json')
    def data(self, **kw):
        """This method showcases how you can use the same controller for a data page and a display page"""
        return dict(params=kw)
    @expose('moviedemo.templates.authentication')
    def auth(self):
        """Display some information about auth* on this application."""
        return dict(page='auth')

    @expose('moviedemo.templates.index')
    @require(predicates.has_permission('manage', msg=l_('Only for managers')))
    def manage_permission_only(self, **kw):
        """Illustrate how a page for managers only works."""
        return dict(page='managers stuff')

    @expose('moviedemo.templates.index')
    @require(predicates.is_user('editor', msg=l_('Only for the editor')))
    def editor_user_only(self, **kw):
        """Illustrate how a page exclusive for the editor works."""
        return dict(page='editor stuff')

    @expose('moviedemo.templates.login')
    def login(self, came_from=url('/')):
        """Start the user login."""
        login_counter = request.environ['repoze.who.logins']
        if login_counter > 0:
            flash(_('Wrong credentials'), 'warning')
        return dict(page='login', login_counter=str(login_counter),
                    came_from=came_from)

    @expose()
    def post_login(self, came_from='/'):
        """
        Redirect the user to the initially requested page on successful
        authentication or redirect her back to the login page if login failed.

        """
        if not request.identity:
            login_counter = request.environ['repoze.who.logins'] + 1
            redirect('/login',
                params=dict(came_from=came_from, __logins=login_counter))
        userid = request.identity['repoze.who.userid']
        flash(_('Welcome back, %s!') % userid)
        redirect(came_from)

    @expose()
    def post_logout(self, came_from=url('/')):
        """
        Redirect the user to the initially requested page on logout and say
        goodbye as well.

        """
        flash(_('We hope to see you soon!'))
        redirect(came_from)


====
Thanks and Regards,

|== Alind Sharma ==|

alind

unread,
Feb 4, 2012, 5:08:32 AM2/4/12
to TurboGears
bump up. I am still stuck with the problem. any solutions?

alind

unread,
Feb 4, 2012, 12:42:34 PM2/4/12
to TurboGears
I tried a simple application bu tit also dose not work. :(
#from sprox.tablebase import TableBase
from sprox.dojo.tablebase import DojoTableBase as TableBase
class BTable(TableBase):
__model__ = BookTable
b_table = BTable(DBSession)

#from sprox.fillerbase import TableFiller
from sprox.dojo.fillerbase import DojoTableFiller as TableFiller
class BTableFiller(TableFiller):
__model__ = BookTable
b_table_filler = BTableFiller(DBSession)

from tgext.crud import CrudRestController
class BController(CrudRestControl
ler):

from tgext.crud import CrudRestController
class BController(CrudRestController):
model = BookTable
table = b_table
table_filler = b_table_filler

And here is the traceback
http://pylonshq.com/tracebacks/0c78af75b7dea53bf8fe3ebb13a6dc1f




Alessandro Molina

unread,
Feb 5, 2012, 5:38:19 AM2/5/12
to turbo...@googlegroups.com
Actually we should probably remove the dojo part from the
documentation as it is currently unmaintained and some of the packages
like tw.dojo have been abandoned. I would suggest you not to use the
dojo based widgets.
They have been disabled by default a few releases ago and there is a
reason for that :)

> --
> You received this message because you are subscribed to the Google Groups "TurboGears" group.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to turbogears+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/turbogears?hl=en.
>

alind

unread,
Feb 5, 2012, 8:36:28 AM2/5/12
to TurboGears
Thanks for the information about dojo.
Actually I wanted to have to meet two specific goals wrt to table
views.
1) Infinitely scrollable list (as promised by dojotable)
2) clicking on the headers should sort the table on that order (one
click-increasing order, another click- decreasing order)
Any idea on this or probably I should ask it on sprox mailing list.

On Feb 5, 3:38 pm, Alessandro Molina <alessandro.mol...@gmail.com>
wrote:

Patricio Valarezo

unread,
Feb 5, 2012, 9:22:56 AM2/5/12
to turbo...@googlegroups.com
El 04/02/12 12:42, alind escribi�:

I have had the same problem, and I solved creating my own get_all method:

@expose('teleconsulta.templates.usuarios.index')
def get_all(self):
return dict(tabla_form =
tabla_usuario,valores=tabla_filler_usuario)

and in the view:
...
<div py:content="tabla_form(value=valores.get_value())">values from
table</div>
...

Note the get_value() call in valores, without it, I had a similar
traceback as yours..

I hope it may help you.

Patricio

--
Patricio Valarezo Lozano.
pato...@pupilabox.net.ec
www.pupilabox.net.ec
"las cosas no se hacen solas, alguien las tiene que hacer..."

Reply all
Reply to author
Forward
0 new messages