After upgrading to web2py version 1.76.5 one of the functions I
defined no longer works.
I defined a table newsmonth:
db.define_table('newsmonth',
db.Field('number',type='integer',length=2,default='',notnull=True),
db.Field('month',length=14,default='',notnull=True,unique=True),
db.Field('publish',type='boolean'),
migrate=False)
... which I use to display archived news items per month. Number is
the number of the month e.g April 4. Month is a string, for April it
reads like: April 2010. Publish defaults to false and is set to true
on the 1st of the next month.
In the view I have a list with links:
March 2010
february 2010
january 2010
When the visitor clicks March 2010, the news table is queried:
def archive():
months=db(db.newsmonth.publish==True).select(db.newsmonth.ALL,orderby=~db.newsmonth.id)
news=[]
month=[]
if request.args:
news=db(db.news.publishing_date.month()==request.args[0])\
.select(db.news.ALL,orderby=~db.news.publishing_date)
month=request.args[1]
if not news:
response.flash='Select an archived month'
else:
response.flash='Select an archived month'
return dict(months=months,news=news,month=month)
month is set to request.args[1], i.e March 2010, and returned to the
view:
<div id="twoColLayout">
<div id="primarycontent">
....
<div id="month">
<h3>Nieuws {{=month.replace('_',' ')}}</h3>
<table>
<thead>
<tr>
<td></td>
</tr>
</thead>
<tbody>
{{for item in news:}}
<tr>
<td>
<h5>{{=db.news.publishing_date.formatter(item.publishing_date)}}</h5>
</td>
<td>
{{=A(item.title,_onmouseover="this.style.cursor='pointer';",\
_onclick="javascript:newsdetails('%s')"%URL(r=request,f='details',args=[item.id]))}}
</td>
</tr>
{{pass}}
</tbody>
</table>
</div> <!-- month -->
</div> <!-- primarycontent -->
<div id="sidecontent">
<div class="sidebox">
<h3>Archived months:</h3>
<table>
<tbody>
{{for month in months:}}
<tr>
<td>
{{=A(month.month,_href=URL(r=request,args=[month.number,month.month]))}}
</td>
</tr>
{{pass}}
</tbody>
</table>
</div> <!-- sidebox -->
</div> <!-- sidecontent -->
</div> <!-- twoColLayout -->
When I expose the archive function, the view displays well. The URL
reads like: http://127.0.0.1:8000/init/news/archive
However, when I click one of the archived months links I get an
invalid request error.
The link in the view reads like: <a href="init/news/archive/3/March
%202010">March 2010</a>
... the URL in the browser reads like:
http://127.0.0.1:8000/init/news/archive/3/March%202010
Since the function works without args, I suppose the error has
something to do with the args, the porblem is I can't figure out what.
Kind regards,
Annet.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" 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/web2py?hl=en.