Web2py Layout Features

CHAPTER 5. DEVELOPMENT
In the Web2py framework there are two objects that contribute in designing both static and dynamic web pages. The SQLFORM.factory object is used for developing static web pages and SQLFORM object for developing dynamic pages.
The framework consists of three files, namely db.py which is created in the model, default.py created in the controller and “default/index.html” file for designing the web page in the view layer.
When the function in the controller gets executed, the “default/index.html” file in the view is called which passes the variables into HTML. Since the view file is written in HTML, the python code is placed within {{ }}. The “layout.html” file represents the fundamental layout of all the applications designed in web2py.
Screenshot of the files mentioned above in web2py interface:

Don't use plagiarized sources. Get Your Custom Essay on
Web2py Layout Features
Just from $13/Page
Order Essay

Screenshot 5.1. Files of Web2py
To understand how the objects work I developed a static web page which takes name and chemical type of a chemical compound as user inputs and accepts the form if no errors are found. However, if the user does not enter any name the form sends a response to the user displaying “Form contains error”
Each time a new user submits the form message “Form displayed for the first time” is displayed.
Screenshot of the web page implemented:

Screenshot 5.1. New page
Code to implement static web page in the logical layer:
def index():
form=SQLFORM.factory(Field(‘Name’,requires=IS_NOT_EMPTY()),
Field(‘Chemical_Type’,requires=IS_NOT_EMPTY())).process()
if form.accepted:
session.flash=”Form accepted”
redirect(URL(‘other’,vars={‘Name’:form.vars.Name}))
elif form.errors:
response.flash=”Form contains errors”
else:
response.flash=”Form displayed for the first time”
return locals()
Code to view the web page in the view layer:
{{extend ‘layout.html’}}
{{=form}}
5.2. Designing dynamic Cheminformatics Application
To start with designing the web application in web2py framework, there are some built-in files that can be modified for designing purpose. These built-in files of web2py have facilitated easy designing of the web application. One of the main files is the ‘menu.py’ model file which can be customized based on the requirement of the user.
By making some few changes in the above file, the following tags such as ‘Cheminformatics’, ‘Home’ and ‘Drug Database’ on the left-hand side of the page have been established.
The table includes Compound_ID and row.id details of the chemical compound table created in the db.py file of model. Logic is implemented in the controller and connecting the web page to the server is implemented in the view. The web page retrieves results from the server based on the query of the user.
Model Code –
db.define_table (‘Compound_Details’,Field(‘Compound_ID,’string’),Field(‘row.id’,’int’))
Controller code-
def index():
return dict()
#search through search bar
def search():
result=””
error=”no result found”
x=request.body.read()
result=Query_results(str(x))
if result!=”: return result
else:
return error
def Query_results(y):
a=””
result=””
count1=0
my_query=(db.Compound_Details.Compound_ID.contains(y))
myset=db(my_query)
rows = myset.select()
for row in rows:
result=str(row.Compound_ID) +’t’+ str(row.id) +’n’+ result
count1=myset.count()
if count1==0:
return str(a)
else: return result
View code-
{{extend ‘layout.html’}}

” [14]
Explanation of the code:
The web2py framework provides the ability to the developer to view the creation of table in the sql.log file and input records into the database through the database administration file.
Below is a snapshot of the implementation of the search page:
Screenshot 5.2. Cheminformatics App page
Three functions are declared in the controller section which includes the logic required to search for text based on user input. In the search function, when user enters text in the search box, the input is converted into string using the request.body.read object.
The string is then directed to the database server through the Query_results function which retrieves ‘Name and row.id of the chemical compound each time count1==0. The index function in the controller is used for the purpose of returning the dictionary.
The view section handles the display of the web page. In order to connect the HTML page to the database server of web2py, an AJAX script is initiated for the purpose of making the page dynamic. It automatically updates the web page without re-loading it. It uses XmlHttpRequest object to interact with the server. Browsers such as IE7+, Firefox, Chrome, Opera, and Safari are supported by the new XmlHttpRequest object. The older versions of IE such as IE5 and IE6 are supported by the new ActiveXObject. Methods open() and send(), are used for the purpose of sending request to the server. The open() method has the following syntax:

open(method,url,async): The method defines the type of Http request to be sent across- either GET or POST. The url is the position of the file and async determines the asynchronous or synchronous nature of request. An asynchronous request is one that does not block the javascript which interacts with the server. A synchronous request is one that hinders the interaction of the javascript with the server until the action is complete. The code in view applies the asynchronous request that facilitates the http request to interact with the server to retrieve the results.
send(string): The argument string is used for http POST request. This method is used for sending the request to the server.
The POST request will then use the setRequestHeader(header,value) method for sending request to the server. ‘Header’ argument is for the header name and the ‘value’ argument is the header value. The following screenshot illustrates the value of the records after the user clicks on the search button.
Screenshot 5.2. Result
This initial prototype will serve as a foundation in the preparation of the cheminformatics resource that will facilitate search based on user input.  

What Will You Get?

We provide professional writing services to help you score straight A’s by submitting custom written assignments that mirror your guidelines.

Premium Quality

Get result-oriented writing and never worry about grades anymore. We follow the highest quality standards to make sure that you get perfect assignments.

Experienced Writers

Our writers have experience in dealing with papers of every educational level. You can surely rely on the expertise of our qualified professionals.

On-Time Delivery

Your deadline is our threshold for success and we take it very seriously. We make sure you receive your papers before your predefined time.

24/7 Customer Support

Someone from our customer support team is always here to respond to your questions. So, hit us up if you have got any ambiguity or concern.

Complete Confidentiality

Sit back and relax while we help you out with writing your papers. We have an ultimate policy for keeping your personal and order-related details a secret.

Authentic Sources

We assure you that your document will be thoroughly checked for plagiarism and grammatical errors as we use highly authentic and licit sources.

Moneyback Guarantee

Still reluctant about placing an order? Our 100% Moneyback Guarantee backs you up on rare occasions where you aren’t satisfied with the writing.

Order Tracking

You don’t have to wait for an update for hours; you can track the progress of your order any time you want. We share the status after each step.

image

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

Areas of Expertise

Although you can leverage our expertise for any writing task, we have a knack for creating flawless papers for the following document types.

image

Trusted Partner of 9650+ Students for Writing

From brainstorming your paper's outline to perfecting its grammar, we perform every step carefully to make your paper worthy of A grade.

Preferred Writer

Hire your preferred writer anytime. Simply specify if you want your preferred expert to write your paper and we’ll make that happen.

Grammar Check Report

Get an elaborate and authentic grammar check report with your work to have the grammar goodness sealed in your document.

One Page Summary

You can purchase this feature if you want our writers to sum up your paper in the form of a concise and well-articulated summary.

Plagiarism Report

You don’t have to worry about plagiarism anymore. Get a plagiarism report to certify the uniqueness of your work.

Free Features $66FREE

  • Most Qualified Writer $10FREE
  • Plagiarism Scan Report $10FREE
  • Unlimited Revisions $08FREE
  • Paper Formatting $05FREE
  • Cover Page $05FREE
  • Referencing & Bibliography $10FREE
  • Dedicated User Area $08FREE
  • 24/7 Order Tracking $05FREE
  • Periodic Email Alerts $05FREE
image

Our Services

Join us for the best experience while seeking writing assistance in your college life. A good grade is all you need to boost up your academic excellence and we are all about it.

  • On-time Delivery
  • 24/7 Order Tracking
  • Access to Authentic Sources
Academic Writing

We create perfect papers according to the guidelines.

Professional Editing

We seamlessly edit out errors from your papers.

Thorough Proofreading

We thoroughly read your final draft to identify errors.

image

Delegate Your Challenging Writing Tasks to Experienced Professionals

Work with ultimate peace of mind because we ensure that your academic work is our responsibility and your grades are a top concern for us!

Check Out Our Sample Work

Dedication. Quality. Commitment. Punctuality


Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 1021 Disk full (/tmp/#sql-temptable-57e-1e32-105a.MAI); waiting for someone to free some space... (errno: 28 "No space left on device") in /home/assignmentnsolut/assignmentresearchwriter.com/prox-classes/Database/DbPDOCore.php:147 Stack trace: #0 /home/assignmentnsolut/assignmentresearchwriter.com/prox-classes/Database/DbPDOCore.php(147): PDO->query('\n SE...') #1 /home/assignmentnsolut/assignmentresearchwriter.com/prox-classes/Database/DbCore.php(379): Proxim\Database\DbPDOCore->_query('\n SE...') #2 /home/assignmentnsolut/assignmentresearchwriter.com/prox-classes/Database/DbCore.php(616): Proxim\Database\DbCore->query('\n SE...') #3 /home/assignmentnsolut/assignmentresearchwriter.com/wp-content/plugins/samples/samples.php(71): Proxim\Database\DbCore->executeS('\n SE...') #4 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/shortcodes.php(433): Proxim_Samples::displaySamples('', '', 'display_samples') #5 [internal function]: do_shortcode_tag(Array) #6 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/shortcodes.php(273): preg_replace_callback('/\\[(\\[?)(displa...', 'do_shortcode_ta...', '[display_sample...') #7 /home/assignmentnsolut/assignmentresearchwriter.com/wp-content/themes/assignmentmavens/widgets/samples.php(8): do_shortcode('[display_sample...') #8 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/template.php(792): require('/home/assignmen...') #9 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/template.php(725): load_template('/home/assignmen...', false, Array) #10 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/general-template.php(206): locate_template(Array, true, false, Array) #11 /home/assignmentnsolut/assignmentresearchwriter.com/wp-content/themes/assignmentmavens/single.php(46): get_template_part('widgets/samples') #12 /home/assignmentnsolut/assignmentresearchwriter.com/wp-includes/template-loader.php(106): include('/home/assignmen...') #13 /home/assignmentnsolut/assignmentresearchwriter.com/wp-blog-header.php(19): require_once('/home/assignmen...') #14 /home/assignmentnsolut/assignmentresearchwriter.com/index.php(17): require('/home/assignmen...') #15 {main} thrown in /home/assignmentnsolut/assignmentresearchwriter.com/prox-classes/Database/DbPDOCore.php on line 147