How to link a default function to html

17 views
Skip to first unread message

Maurice Waka

unread,
Mar 16, 2017, 12:41:28 PM3/16/17
to web2py-users
my code goes like this:


db.py

db.define_table('category', Field('name', requires = (IS_LOWER(), IS_SLUG(), IS_NOT_IN_DB(db, 'category.name'))))

db.define_table( 'searches',
                        Field('body', 'text', requires = (IS_NOT_EMPTY(), IS_LOWER())),
                                label = ''),
                        auth.signature)

def view_searches():
    id = request.args(0, cast=int)
    searches = db.searches(id) or redirect(URL('index'))
    form1 = [searches.body]
    name3 = ''.join(form1)
    code........

def create_searches():
    category = get_category
    form =SQLFORM(db.searches, id, showid =False,).process(next = 'view_searches/[id]')
    return locals()


in view section for create_serches:


<!DOCTYPE html>
<html>
<head>
<title>BritamIntell</title>
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'css/create_searches.css')}}">
</head>
<body>
<div class="chatbox">

<div class="chatlogs">
<div class="chat friend">
<div class="user-photo"><img src="{{=URL('static','images/userOne.png')}}"/></div>
<p class="chat-message">More code needed</p>
</div>
<div class="chat self">
<div class="user-photo"><img src="{{=URL('static','images/userTwo.png')}}"/></div>
                <p class="chat-message"><a href="view_searches.html"/a>
                    {{for item in name3:}}
                        {{while True:}}{{break}}
                        <div class = "well">
                            <table>
                                <tr>
                                    <td>
                                        <p>
                                           <font size="3" face="lucida sans unicode" color="blue">{{='Answer:'}}</font><br/>
                                           <font size="2.5" face="lucida sans unicode" color="darkblue">{{=XML(report.replace('\n','<br>'))}}{{break}}
                                            </font><br/>
                                        </p>
                                    </td>
                                </tr>
                            </table>
                        {{pass}}
                        {{pass}}
                        {{pass}}
                </a></li></p>
</div>
</div>
<div class="chat-form">
{{=form}}
</d>
</div>

</body>
</html>


My biggest problem is linking at the chat.self and chat.friend in view html for create_searches.
I cant seem to connect/link to and from the view_searches in default which happens to have a function code that works to get a message from 'form' and post it on the html page in the create_searches.
This is like a chat-bot with someone retrieving items such as names from a db...in this case db.searches. if one inputs(through chat.self) a name such as John, and submits it at chat-form, then the chat.friend looks in the db for the name or other information and posts it back to the page.
Am still learning more with web2py and python and i would  like help and correction where possible
Regards
Reply all
Reply to author
Forward
0 new messages