Re: questions
Mary Jane Boholst <[email protected]> Fri, 27 Oct 2006 14:19:27 +0100
| Newsgroups | gmane.comp.python.spyce.general |
|---|---|
| Organization | IOP |
| Message-ID | <[email protected]> |
If I change the default option to default="unit.day" I get the following error: Spyce exception File: /var/firstproject/www/timetableedit.spy Message: Invalid selected object 1; must be string or container Stack: /usr/share/spyce-2.1/tags/_formhelper.py:26, in find_selected: raise 'Invalid selected object %s; must be string or container' % selected /usr/share/spyce-2.1/tags/form.py:173, in begin: selected = find_selected(self, name, selected, default) /usr/share/spyce-2.1/modules/taglib.py:74, in tagBegin: result = tag.begin(**tag._attrs) timetableedit.spy:44, in (main): <f:select name=day data="[(L.day,L.day) for L in all1]" default="=unit.day" /> I converted unit.day to string as I had received this error several times but did not understand what it meant, I assumed it was to do with the type but obviously it must be to do with something else...? Thank you for your help with this. MJ On Friday 27 October 2006 14:08, Jonathan Ellis wrote: > ah, it's because your days are really ints, but "day" is a string > > the value of "default" needs to match one of the actual values by > python's equality rules, and > > 1 != '1' > > On Fri, 27 Oct 2006 13:55:38 +0100, "Mary Jane Boholst" > > <[email protected]> said: > > The html generated is: > > <select name="day" id="day"><option value="1">1</option><option > > value="2">2</option><option value="3">3</option><option > > value="4">4</option><option value="5">5</option></select></td> > > > > On Friday 27 October 2006 13:51, you wrote: > > > What html is being generated for the select? > > > > > > On Fri, 27 Oct 2006 11:15:46 +0100, "Mary Jane Boholst" > > > > > > <[email protected]> said: > > > > Hello again, > > > > Sorry I should have put this question in with the other one. I have > > > > created a > > > > drop down menu using the following code: > > > > <SNIP> > > > > [[id = session.get('id')]] > > > > [[unit = db.timetable.selectone_by(id=id)]] > > > > [[day = str(unit.day)]] > > > > [[all1=db.timetable.select(db.timetable.c.starttime=='09:00', > > > > distinct=True)]] > > > > <SNIP> > > > > <f:form> > > > > <SNIP> > > > > <f:select name=day data="[(L.day,L.day) for L in all1]" > > > > default="=day" /> <SNIP> > > > > </f:form> > > > > However the default option does not seem to be working. Can anyone > > > > shed some > > > > light on why this might be so? > > > > thanks in advance, > > > > MJ > > > > > > > > Jonathan Ellis wrote: > > > > > you can, but SqlSoup won't turn it into objects for you... > > > > > > > > > > use db.timetable._table to get the underlying SqlAlchemy table > > > > > object, with which you can do lower-level selects > > > > > (see http://www.sqlalchemy.org/docs/sqlconstruction.myt -- further > > > > > questions on that are better directed to the SA mailing list) > > > > > > > > > > or, just grab db.engine and write raw sql > > > > > > > > > > On Tue, 24 Oct 2006 16:30:53 +0100, "Mary Jane Boholst" > > > > > > > > > > <[email protected]> said: > > > > >> does that mean that I cannot do the SQL "select distinct day from > > > > >> timetable;" which is what I was trying to achieve? > > > > >> Thanks again. > > > > >> MJ > > > > >> > > > > >> Jonathan Ellis wrote: > > > > >>> the first argument to select must be a (where) clause of some > > > > >>> sort; [db.timetable.c.day] is invalid > > > > >>> > > > > >>> a suggestion: when trying something new, change one thing at a > > > > >>> time. obviously this statement didn't work before adding the > > > > >>> "distinct;" if you had started with a working statement and then > > > > >>> added distinct, it would have been clear where the problem was > > > > >>> [not]. > > > > >>> > > > > >>> On Tue, 24 Oct 2006 09:53:28 +0100, "Mary Jane Boholst" > > > > >>> > > > > >>> <[email protected]> said: > > > > >>>> Thank you for the clarification. What is the syntax for the use > > > > >>>> of distinct=True with the select statement. I seem to be getting > > > > >>>> errors with the following syntax: > > > > >>>> days=db.timetable.select([db.timetable.c.day], distinct=True). > > > > >>>> Thanks again for all your help. > > > > >>>> MJ > > > > >>>> > > > > >>>> On Monday 23 October 2006 17:32, Jonathan Ellis wrote: > > > > >>>>> As discussed in a recent thread with someone else, you cannot > > > > >>>>> use [[= inside an active tag. just prefix a value with = to > > > > >>>>> cause it to be eval'd instead. (The only exception is the > > > > >>>>> "data" attribute which is _always_ eval'd like this.) So, > > > > >>>>> > > > > >>>>> <f:select name=day data="[L.day for L in all]" > > > > >>>>> default="=unit.day" /> > > > > >>>>> > > > > >>>>> btw, distinct=True does nothing in f:select, perhaps you meant > > > > >>>>> to put it in timetable.select(). > > > > >>>>> > > > > >>>>> On Mon, 23 Oct 2006 15:26:45 +0100, "Mary Jane Boholst" > > > > >>>>> > > > > >>>>> <[email protected]> said: > > > > >>>>>> Hi, > > > > >>>>>> OK. I have added the tag with the default attribute (attached > > > > >>>>>> file) but > > > > > > > > I > > > > > > > > >>>>>> now > > > > >>>>>> do not get anything displayed in the column in the table. The > > > > >>>>>> page displays > > > > >>>>>> but there are no drop down menus. This is rather strange. The > > > > >>>>>> spyce compiler > > > > >>>>>> does not seem to be complaining about the code but nothing is > > > > > > > > displayed. > > > > > > > > >>>>>> Is > > > > >>>>>> there something wrong with my code that I am just not seeing? > > > > >>>>>> Is this something to do with the browser that I am using? Any > > > > >>>>>> help will be gratefully > > > > >>>>>> received. > > > > >>>>>> Thanks very much for all your help. > > > > >>>>>> MJ > > > > >>>>>> > > > > >>>>>> On Monday 23 October 2006 14:54, Jonathan Ellis wrote: > > > > >>>>>>> use the "default" attribute > > > > >>>>>>> > > > > >>>>>>> <f:select data=... default=onevalue /> > > > > >>>>>>> > > > > >>>>>>> On Mon, 23 Oct 2006 14:05:31 +0100, "Mary Jane Boholst" > > > > >>>>>>> > > > > >>>>>>> <[email protected]> said: > > > > >>>>>>>> Hello again, > > > > >>>>>>>> I am having problems with the <f:select> tag and having a > > > > >>>>>>>> particular value selected on a page. Basically what I want > > > > >>>>>>>> to do is have the day that is in a particular row of a > > > > >>>>>>>> database selected in the drop down menu. Is there a way for > > > > >>>>>>>> me to do this? > > > > >>>>>>>> Thanks in advance for any help given. > > > > >>>>>>>> MJ > > > > >>>>>>>> PS sorry for any bounced email, the email address I use is a > > > > >>>>>>>> valid one as it is a work address. I have no idea why this > > > > >>>>>>>> would happen. > > > > >>>>>>>> > > > > >>>>>>>> Jonathan Ellis wrote: > > > > >>>>>>>>> Try <%= day %> to see if it's a sequence before using it in > > > > >>>>>>>>> the f:select > > > > >>>>>>>>> > > > > >>>>>>>>> just add ", distinct=True" to your select args to perform > > > > >>>>>>>>> "select distinct," although I would guess that something's > > > > >>>>>>>>> wrong with your model if days in the timetable are not > > > > >>>>>>>>> already unique :) > > > > >>>>>>>>> > > > > >>>>>>>>> On Fri, 13 Oct 2006 11:48:07 +0100, "Mary Jane Boholst" > > > > >>>>>>>>> > > > > >>>>>>>>> <[email protected]> said: > > > > >>>>>>>>>> I keep > > > > >>>>>>>>>> getting an error when I try to use the <f:select> tag > > > > >>>>>>>>>> with/ data="[d.day for d in day]"/ where > > > > >>>>>>>>>> /day=db.timetable.select(order_by=[db.timetable.c.day])/. > > > > >>>>>>>>>> The error is TypeError:unpack non-sequence. Any help with > > > > >>>>>>>>>> why this is not working would be useful. Also is there a > > > > >>>>>>>>>> way of doing the sql query "select distinct day from > > > > >>>>>>>>>> timetable;" in spyce/sqlalchemy? Thanks for all your help. > > > > >>>>>>>>>> MJ > > > > >>>>>>>>>> > > > > >>>>>>>>>> Jonathan Ellis wrote: > > > > >>>>>>>>>>> On Tue, 19 Sep 2006 15:25:33 +0100, "Mary Jane Boholst" > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> <[email protected]> said: > > > > >>>>>>>>>>>> Hello again, > > > > >>>>>>>>>>>> I am currently attempting to develop a web interface > > > > >>>>>>>>>>>> linked to a database and was wondering if anyone knew > > > > >>>>>>>>>>>> how I could display the contents of a table or part > > > > >>>>>>>>>>>> table in a database as a table in a web page. Failing > > > > >>>>>>>>>>>> that does anyone know of somewhere where I could find an > > > > >>>>>>>>>>>> example? > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> get a list of data from the db, and display it with > > > > >>>>>>>>>>> spy:table or a manual for loop. > > > > >>>>>>>>>>> > > > > >>>>>>>>>>>> Also is there a way of creating drop down lists using a > > > > >>>>>>>>>>>> database connection to populate the contents of the drop > > > > >>>>>>>>>>>> down menu? > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> same things, only with f:select. > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> it is almost the same as using spy:ul as shown over here: > > > > >>>>>>>>>>> http://spyce.sourceforge.net/docs/whats-new-2-1.html > > > > >>>>>>>>>>> > > > > >>>>>>>>>>> -Jonathan > > > > >>>>>>>> > > > > >>>>>>>> ------------------------------------------------------------ > > > > >>>>>>>>---- ----- ---- Using Tomcat but need to do more? Need to > > > > >>>>>>>> support web services, security? Get stuff done quickly with > > > > >>>>>>>> pre-integrated technology to make your job easier > > > > >>>>>>>> Download IBM WebSphere Application Server v.1.0.1 based on > > > > >>>>>>>> Apache Geronimo > > > > >>>>>>>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=26305 > > > > >>>>>>>>7&da t=121 642 > > > > >>>>>>>> _______________________________________________ Spyce-users > > > > >>>>>>>> mailing list > > > > >>>>>>>> [email protected] > > > > >>>>>>>> https://lists.sourceforge.net/lists/listinfo/spyce-users > > > > > > > > --------------------------------------------------------------------- > > > >---- Using Tomcat but need to do more? Need to support web services, > > > > security? Get stuff done quickly with pre-integrated technology to > > > > make your job easier > > > > Download IBM WebSphere Application Server v.1.0.1 based on Apache > > > > Geronimo > > > > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121 > > > >642 _______________________________________________ > > > > Spyce-users mailing list > > > > [email protected] > > > > https://lists.sourceforge.net/lists/listinfo/spyce-users ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642