Hello People,

I'm trying to inject JS resources (Dojo testUpdatingChart script) on
the way out from the ObjectDispatchController.  I've subclassed
TableForm in a Widget to attach the javascript to.  Ultimately, I want
to animate visualisations of generated data coming out of the DB.  But
first I wanted to see some Dojo bells and whistles tacked on for wow
factor.


I get the following error:

"TypeError: pic() takes exactly 3 arguments (1 given)"

I guess this kind of error might be as common as ImportError, so may I
present some context. Working from "front to back"...


In /templates I have...
================
    <h1>The Plot</h1>
    <br/>
    <div id="testUpdating" style="width: 300px; height: 300px;">
        This text will be replaced by a chart, I hope...
    </div>
    <!-- Or maybe something like this'll work...-->
    <div py:replace="tmpl_context.form(
        child_args=dict( fig = dict(id=1,
                                    title='Test Plot',
                                    fig='wijdrgpi4thaerhgoq34itwie'
                                    )
                       )">Input Form</div>
    <!-- Or maybe I've lost The Plot -->


In /widgets I have...
===============
class TestPic(TableForm):
    template = "pkg.templates.chart.html"
    js = [JSLink(link=url('/public/js/chart.js'))]

    class fields(WidgetsList):
         id = TextField()
         title = TextField()
         fig = TextArea()

create_test_pic = TestPic("create_test_pic")


In my controller method in root.py I have ...
================================
    @expose("pkg.templates.pic")
    def pic(self, title, fig):
        tmpl_context.form = create_test_pic
        pic = DBSession.query(Pic).filter_by(title=title).one()
        pic.fig = fig
        return dict(wikipage=pic)


If you hadn't guessed my model has in it...
=================================
class Pic(DeclarativeBase):
    __tablename__ = 'pic'

    id = Column(Integer, primary_key=True)
    title = Column(Text, unique=True)
    fig = Column(Text) #gav Column(BLOB) #Ins img here eg. gif, jpg or
png

    def __init__(self, title, fig):
        self.title = title
        self.fig = fig


So the constructor takes 3 args. OK, fine but how do they get passed
in from the front end?  Presumably the template <div... fields are
sent in a Pylons/WebOb.request environ thingumajig and ultimately to
my controller.  Or do I have to put it in the DB first?  If I do, I
get the same kind of error on __init__.  I seem to be going in circles
here.  Is there some simple, key point about the way TG passes params
that I'm missing?  The WebError Traceback seems unhelpful in this
instance but I'll attach it at the end in case it's useful.


URL: http://127.0.0.1:8080/pic
File 'c:\\tg-env\\lib\\site-packages\\weberror-0.10.1-py2.5.egg\
\weberror\\evalexception.py', line 431 in respond
  app_iter = self.application(environ, detect_start_response)
File 'c:\\tg-env\\lib\\site-packages\\turbogears2-2.0-py2.5.egg\\tg\
\configuration.py', line 643 in wrapper
  return app(environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\turbogears2-2.0-py2.5.egg\\tg\
\configuration.py', line 543 in remover
  return app(environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\repoze.tm2-1.0a4-py2.5.egg\
\repoze\\tm\\__init__.py', line 19 in __call__
  result = self.application(environ, save_status_and_headers)
File 'c:\\tg-env\\lib\\site-packages\\repoze.who-1.0.10-py2.5.egg\
\repoze\\who\\middleware.py', line 107 in __call__
  app_iter = app(environ, wrapper.wrap_start_response)
File 'c:\\tg-env\\lib\\site-packages\\toscawidgets-0.9.4-py2.5.egg\\tw\
\core\\middleware.py', line 36 in __call__
  return self.wsgi_app(environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\toscawidgets-0.9.4-py2.5.egg\\tw\
\core\\middleware.py', line 59 in wsgi_app
  resp = req.get_response(self.application)
File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1325 in
get_response
File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1293 in
call_application
File 'c:\\tg-env\\lib\\site-packages\\toscawidgets-0.9.4-py2.5.egg\\tw\
\core\\resource_injector.py', line 67 in _injector
  resp = req.get_response(app)
File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1325 in
get_response
File 'build\\bdist.win32\\egg\\webob\\__init__.py', line 1293 in
call_application
File 'c:\\tg-env\\lib\\site-packages\\beaker-1.3-py2.5.egg\\beaker\
\middleware.py', line 81 in __call__
  return self.app(environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\beaker-1.3-py2.5.egg\\beaker\
\middleware.py', line 160 in __call__
  return self.wrap_app(environ, session_start_response)
File 'c:\\tg-env\\lib\\site-packages\\routes-1.10.3-py2.5.egg\\routes\
\middleware.py', line 130 in __call__
  response = self.app(environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\\pylons\
\wsgiapp.py', line 125 in __call__
  response = self.dispatch(controller, environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\\pylons\
\wsgiapp.py', line 324 in dispatch
  return controller(environ, start_response)
File 'C:\\tg-env\\Proj\\pkg\\lib\\base.py', line 32 in __call__
  return TGController.__call__(self, environ, start_response)
File 'c:\\tg-env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\\pylons\
\controllers\\core.py', line 221 in __call__
  response = self._dispatch_call()
File 'c:\\tg-env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\\pylons\
\controllers\\core.py', line 172 in _dispatch_call
  response = self._inspect_call(func)
File 'c:\\tg-env\\lib\\site-packages\\pylons-0.9.7-py2.5.egg\\pylons\
\controllers\\core.py', line 107 in _inspect_call
  result = self._perform_call(func, args)
File 'c:\\tg-env\\lib\\site-packages\\turbogears2-2.0-py2.5.egg\\tg\
\controllers.py', line 806 in _perform_call
  self, controller, params, remainder=remainder)
File 'c:\\tg-env\\lib\\site-packages\\turbogears2-2.0-py2.5.egg\\tg\
\controllers.py', line 172 in _perform_call
  output = controller(*remainder, **dict(params))
TypeError: pic() takes exactly 3 arguments (1 given)

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

Reply via email to