Friends,
I have two Problems in my blog App (running in GAE).
1) In the code that generate the RSS by category:
- It's run but only if I don't put the orderby declaration in
db.select() method but
I need to sort my posts by ~created(DESC created) date to
generate my RSS feeds.
My RSS function:
def rss():
import datetime
response.headers['Content-Type']='application/rss+xml;charset=utf-8'
import gluon.contrib.rss2 as rss2
try:
cat_name = request.args[0]
if cat_name == 'all':
cat_name = ''
if cat_name != '' :
cat =
db(db.categories.name==cat_name).select()[0]
# This code generate a Exception
#posts = db(
# (db.posts.category ==
cat.id)
# ).select(db.posts.ALL,
orderby=~db.posts.created)
# This code run OK.
posts = db(
(db.posts.category ==
cat.id)
).select(db.posts.ALL)
else:
posts = db().select(db.posts.ALL,
orderby=~db.posts.created)
except Exception, e:
raise e
.... more code ....
2) Filter posts by category name with name in Portuguese:
- I have a function that show-me the posts in determined
category,
but if the category name is writted with especial characters/
Latin characters I receive a Exception.
My posts by category function:
# If request.args[0] is 'News' run OK
# If request.args[0] is 'Programação' I receive a Exception
def category():
try:
cat_name = request.args[0]
cat = db(db.categories.name==cat_name).select()[0]
recordsby=7
if request.vars.pagina:
page=int(request.vars.pagina)
else:
page=0
totalrecs = len(db((db.posts.category == cat.id)).select
(db.posts.ALL))
posts = db((db.posts.category == cat.id)).select
(db.posts.ALL,limitby=(page*recordsby,(page*recordsby)+recordsby))
backward=A('Anteriores',_href=URL(r=request,args=[cat_name],vars=dict
(pagina=page-1))) if page else ''
forward=A('Próximos',_href=URL(r=request,args=[cat_name],vars=dict
(pagina=page+1))) if totalrecs>((page*recordsby)+recordsby) else ''
response.rss_url = "/blog/rss/%s/" % cat_name
return dict(posts = posts,backward=backward,forward=forward)
except Exception, e:
raise e
How to resolve this two problems ?
--
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.