ob1.data schrieb:
> 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.

This has nothing todo with TG/Pylons/TW. It's solely about your model, 
which you gave a constructor that's requiring a Pic-object being 
constructed without always passing arguments - thus preventing a 
Pic-object from being instantiated *if it already exists* and is only 
supposed to be filled with DB-data.

Remove that constructor, and see how things work out.



Diez

--~--~---------~--~----~------------~-------~--~----~
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