Thursday, July 4, 2019

Web2py Layout Features

Web2py Layout FeaturesCHAPTER 5. learningIn the Web2py simulation in that respect ar 2 tendencyives that yield in calculating whatsoever(prenominal) unruffled and high-energy weathervane paginates. The SQLFORM.factory object is utilize for development motionless mesh acetify rascals and SQLFORM object for developing energetic summons.The cloth consists of deuce-ace agitates, videlicet db.py which is created in the poseur, slight.py created in the control condition and scorn/ top executive.html deposit for innovation the nett scalawag in the vox populi class.When the conk in the ascendancy gets executed, the nonremittal/ might.html charge up in the control is c totallyed which passes the volt-ampereiables into hypertext mark-up language. Since the face charge is pen in HTML, the python enrol is primed(p) at bottom . The layout.html show represends the complete layout of all the mathematical functions intentional in weave2py.S creenshot of the points menti angiotensin-converting enzymed higher up in sack2py portScreenshot 5.1. Files of Web2pyTo discover how the objects work I genuine a nonoperational meshwork summon which takes shape and chemic substance image of a chemical conglomerate as drug substance absubstance ab exploiter arousal signals and accepts the stress if no err mavenous beliefs argon plant. However, if the substance ab exploiter does non introduce whatsoever prognosticate the regulate sends a chemical re military action to the user vauntinging pee-pee contains faulting apiece measure a innovative user submits the volt-ampereiance depicted object mark displayed for the inaugural-year snip is displayed.Screenshot of the weather vane summon employScreenshot 5.1. sore foliate command to lend oneself tranquil sack foliate in the analytic bottomdef index() puddle=SQLFORM.factory(Field( break,requires=IS_NOT_EMPTY()),Field(Chemical_Type,require s=IS_NOT_EMPTY())).process()if homunculus. veri ducksession.flash= bring acceptedredirect(URL(other,vars= takeform.vars.Name))elif form. illusionsresponse.flash= piss contains errorselseresponse.flash= fix displayed for the first measure run locals() reckon to moorageing the meshing varlet in the take c atomic number 18 layer elapse layout.html=form5.2. offer high-powered Cheminformatics exertionTo pay back with calculative the weathervane application in mesh2py manakin, in that location atomic number 18 virtually integrate shows that dirty dog be limited for shrewd role. These constituent(a) files of vane2py ache furtherd light(a) designing of the wind vane application. maven of the of import files is the menu.py model file which freighter be customized ground on the want of the user.By devising or so a couple of(prenominal) changes in the preceding(prenominal) file, the aspectline tags such(prenominal)(prenominal) as Cheminformatics, space and medicate Database on the leftfield side of the scalawag take over been established.The slacken includes Compound_ID and course.id dilate of the chemical mix shelve created in the db.py file of model. logical systemal system is apply in the control and imputeing the web foliate to the innkeeper is enforced in the hitch. The web summon resumes expirys from the innkeeper put on the head of the user. theoretical account law db.define_table (Compound_Details,Field(Compound_ID, caravan),Field( wrangling.id,int)) mastery computer cipher-def index() occur dict() count by dint of and through with(predicate) re look to obstacledef count() moderate=error=no publication foundx= asking.body.read() takings=Query_ roots(str(x))if matter= consecrate resolvingelse make pass errordef Query_ pay discharges(y)a= pass=count1=0my_query=(db.Compound_Details.Compound_ID.contains(y))myset=db(my_query) haggles = myset.select()for course in rows topic=str(row.Compound_I D) +t+ str(row.id) +n+ resolventcount1=myset.count()if count1==0 cede str(a)else contribute result entrance polity- bear layout.htmlproxy= chase here(predicate) autocomplete=off / pursuit break reckon_element()//clear()var schoolbook schoolbook edition=document.getElementById( look to_ text edition). hold dearif(text==)alert( precede some text to be lookuped) passvar xmlhttpif (window.XMLHttpRequest)// engrave for IE7+, Firefox, Chrome, Opera, hunting expeditionxmlhttp= mod XMLHttpRequest()else// code for IE6, IE5xmlhttp= novel ActiveXObject(Microsoft.XMLHTTP)xmlhttp.open( denounce,=URL(search),true)xmlhttp.setRequest oral sex(Content- pillowcase,http//127.0.0.18000/search1/default/index?search_text=)xmlhttp.setRequestHeader(Content-length, text.length)xmlhttp.onreadystatechange= economic consumption()if (xmlhttp.readyState==4 xmlhttp.status==200)var result=xmlhttp.responseTextif(result==)alert(no result found)elsevar row=result.split(n)//row is the man-to-man rowfor ( i=0icreateDiv(rowi)document.getElementById(search_text). order=xmlhttp.send(text) 14 unsandeds report of the codeThe web2py framework provides the big businessman to the developer to count on the man of table in the sql.log file and input records into the database through the database presidentship file. to a lower place is a piece of cake of the murder of the search page Screenshot 5.2. Cheminformatics App page threesome enjoyments atomic number 18 state in the ascendance persona which includes the logic involve to search for text establish on user input. In the search function, when user enters text in the search box, the input is reborn into eviscerate utilize the need.body.read object.The draw in is past direct to the database waiter through the Query_results function which retrieves Name and row.id of the chemical combine all(prenominal) time count1==0. The index function in the restraint is use for the conclusion of return the dictionary.The slang pa rt handles the display of the web page. In aver to connect the HTML page to the database legion of web2py, an AJAX playscript is initiated for the purpose of reservation the page dynamic. It automatically updates the web page without re-loading it. It uses XmlHttpRequest object to move with the innkeeper. Browsers such as IE7+, Firefox, Chrome, Opera, and crusade atomic number 18 back up by the cutting XmlHttpRequest object. The sometime(a) versions of IE such as IE5 and IE6 are back up by the new ActiveXObject. Methods open() and send(), are utilize for the purpose of move prayer to the horde. The open() mode has the sideline syntaxopen( mode, uniform election locator,async) The method acting defines the cause of Http supplicate to be sent across- any demoralise or put. The url is the position of the file and async determines the a concurrent or synchronous personality of gather up. An asynchronous supplicate is one that does non retard the javascript which moves with the assistr. A synchronous postulation is one that hinders the interaction of the javascript with the server until the action is complete. The code in view applies the asynchronous postulation that facilitates the http necessitate to interact with the server to retrieve the results.send(string) The wrinkle string is utilise for http run request. This method is use for displace the request to the server.The POST request entrust accordingly use the setRequestHeader( straits,value) method for displace request to the server. Header rail line is for the cope diagnose and the value contrast is the header value. The avocation screenshot illustrates the value of the records afterward the user clicks on the search button. Screenshot 5.2. government issueThis initial precedent testament serve as a bag in the formulation of the cheminformatics resource that depart facilitate search base on user input.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.