Web2py Components - Web2Py

What is Web2py Components?

A component is defined as the functional a part of an internet web page, which goes autonomously. it can be composed of modules, controllers, and perspectives, which are embedded in a web page. The issue in a utility must be localized tag and the overall performance is taken into consideration to be unbiased of the module.

In web2py, the principle consciousness is on using components which can be loaded in the page and which communicate with the aspect controller via AJAX.

web2py includes a function, that's known as the weight function, which makes implementation of additives easy without explicit JavaScript or AJAX programming.

don't forget an easy internet software namely “check” that extends the web2py utility with the custom version in document “fashions/db_comments.py”.

The above code will create a table “comment_post” with the proper table definition. The action will be implemented with the help of functions in “controllers/comments.py”.

The corresponding view will be displayed as −

The page can be accessed using the given URL − http://127.0.0.1:8000/test/comments/post

The method mentioned above is a traditional way of accessing a view, which can be changed with the implementation of the LOAD function.

This can be achieved by creating a new view with the extension ".load" that does not extend the layout.

The new view created would be "views/comments/post.load" −

The URL to access the page would be − http://127.0.0.1:8000/test/comments/post.load

The LOAD component can be embedded into any other page of web2py application. This can be done by using the following statement.

For example, the Controllers can be edited as −

In View, we can add the component −

The page can be accessed with the URL − http://127.0.0.1:8000/test/default/index

Component Plugins

Component plugins are the plugins, which uniquely define Components. Components access the database directly with their model definition.

As mentioned in the previous example, comments component into a comments_plugin can be done in the Models section −

The Controller will include the following plugin −

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Web2Py Topics