{{extend "layout.html"}}
<html lang="en">
<head>
<link rel="shortcut icon" href="favicon.ico" />
<link href="{{=URL('static', 'css/view_searches.css')}}" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="chat_window">
<ul class="messages">
{{for reply in replies:}}
<li class="message left appeared">
<div>
{{=prettydate(reply.modified_on)}}
</div>
<div class="text_wrapper">
<div class="text">{{=XML(reply.quest, sanitize=True)}}</div>
</div>
</li>
<li class="message right appeared">
<div>
{{=prettydate(reply.modified_on)}}
</div>
<div class="text_wrapper">
<div class="text">{{=XML(reply.message, sanitize=True)}}</div>
</div>
</li>
{{pass}}
</ul>
<div class="bottom_wrapper clearfix">
<div class="message_input_wrapper">
<div class="message_input_wrapper">
{{=form.custom.begin}}
<textarea name="message" id="message_input" placeholder="Type your message here..."></textarea>
<button>send</button>
{{=form.custom.end}}
</div>
</div>
</div>
</div>
<div class="message_template">
<li class="message">
<div class="message-data-time" ></div>
<div class="text_wrapper">
<div class="text"></div>
</div>
</li>
</div>
</body>
replies = db(db.answers.author == auth.user.id).select(db.answers.ALL)[-7:-1]#:-1]##if getting upto the last record, it appears twice when posting on view
question = db(db.answers.author == auth.user.id).select(orderby=~db.answers.created_on,limitby=(2,0))
answer = db(db.answers.author == auth.user.id).select(orderby=~db.answers.created_on, limitby=(2,0))
q = ''
a = ''
for q in question:
q = XML(q.quest, sanitize=True)
for a in answer:
a = XML(a.message, sanitize=True)
return dict(form=form, q=q, a=a, replies=replies)
The first thing is identifying the reason of the slow load. Is the render of the view, the controller, or the data access? you can debug or strip parts of your code to find that.
By example, if your code loads too many questions and/or answers it will be really slow because there will be too many objects in memory.
Greetings.
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
replies = db(db.answers.author == auth.user.id).select(db.answers.ALL)[-7:-1]#:-1]##if getting upto the last record, it appears twice when posting on view
question = db(db.answers.author == auth.user.id).select(orderby=~db.answers.created_on,limitby=(2,0))
answer = db(db.answers.author == auth.user.id).select(orderby=~db.answers.created_on, limitby=(2,0))
q = ''
a = ''
for q in question:
q = XML(q.quest, sanitize=True)
for a in answer:
a = XML(a.message, sanitize=True)
return dict(form=form, q=q, a=a, replies=replies)
{{=form.custom.begin}}
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/O6CxDRViyNA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
Below is the start of the controller code, containing several hundred lines:
form = SQLFORM(Post, formstyle='table3cols',)if form.process().accepted:pass
form = SQLFORM(Post, formstyle='table3cols').process()
row = db(db.post.author == auth.user.id).select(db.post.id, db.post.message,
orderby=~db.post.id,
limitby=(0, 1)).first()
messagev = row.message if row else None
At the limitby(0,2) am using the js code below to obtain the string for the q, and a.
--
Selecting the last item in q or a ends up with:<Row {'message': '....strings....'', 'id': 8135L}>