web2py | open source full-stack enterprise framework | Database library
kandi X-RAY | web2py Summary
kandi X-RAY | web2py Summary
An important part of web2py is the Database Abstraction Layer (DAL). In early 2015 this was decoupled into a separate code-base (PyDAL). In terms of git, it is a sub-module of the main repository. The use of a sub-module requires a one-time use of the --recursive flag for git clone if you are cloning web2py from scratch.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Renders the given text and returns the rendered text .
- Performs an ldap authentication .
- Send message .
- Sets the console version to use .
- Make a subset subset from the specified file .
- Called when a record is accepted .
- Handle wgibase requests .
- Takes a WSDL document and converts it to services .
- Make a jsmin for jsmin .
- Generates a URL
web2py Key Features
web2py Examples and Code Snippets
; App configuration
; db configuration - set migrate=0 once installed
[db]
uri = mysql://oz:passwd@127.0.0.1/OneZoom?set_encoding=utf8mb4
migrate = 1
pool_size = 1
; smtp address and credentials
[smtp]
[twitter]
[forms]
; form styling
for
db.define_table('users',Field('start_date','string'), Field('end_date','string'))
Community Discussions
Trending Discussions on web2py
QUESTION
I have the following code:
...ANSWER
Answered 2021-Jul-13 at 18:17If you are using SQLite, you may have initially defined the field as type double
(or decimal
) and later "migrated" to type string
. As noted here, such migrations have no effect in SQLite, so SQLite will continue to treat the column as numeric and coerce values to numbers when possible (SQLite does not complain about storing non-numeric strings in the column because it does not have rigid column types -- it simply has type affinities, which determine what types of coercions may happen -- see https://www.sqlite.org/datatype3.html).
You'll have to re-create the table, starting with the correct column type.
QUESTION
actually i have a table in the html and i want to know how i can get like tabe.rows.count on python in web2py
here is my code:
...ANSWER
Answered 2021-May-28 at 03:59It seems like you are trying to access a client side element ('TablaMateriales') on the server side. You can only do that if you explicitly pass the element back to the server.
And then you would need to manipulate it using something like http://web2py.com/books/default/chapter/29/05/the-views#Server-side-DOM-and-parsing
You could just count the number of rows using JavaScript from inside the view: JavaScript to get rows count of a HTML table
QUESTION
I am developing web2py - Models - db_testing.py in pythonanywhere.com
below code is running successfully:
...ANSWER
Answered 2021-Apr-03 at 02:27To check whether it's a string: if isinstance(firstname, str)
To check whether non-empty: you can do if firstname != ''
or if firstname
; in Python, empty objects are treated as being "False" when used as a boolean. To check whether it's letter characters, you can do if firstname.isalpha()
.
QUESTION
I run with web2py a rest api in the controller and there my jwt and the token works. In the model I am using fields with default values but this fields are never filled automatically because auth.user is None. I tried to init it manually but it does not work.
Sites.py:
...ANSWER
Answered 2020-Oct-19 at 12:47auth = Auth(db, jwt = {'secret_key':'...', 'user_param':"email"})
QUESTION
I have a csv with utf-8 characters that I want to convert to a pdf using Python's fpdf package.
When I execute the following code, I receive the error, RuntimeError: TTF Font file not found: C:\Windows\Fonts\DejaVuSansCondensed.ttf
Here is the full stack trace:
...ANSWER
Answered 2020-Oct-10 at 02:42Smells like a windows permission issue, according to official docs:
os.path.exists(path) Return True if path refers to an existing path or an open file descriptor. Returns False for broken symbolic links. On some platforms, this function may return False if permission is not granted to execute os.stat() on the requested file, even if the path physically exists.
so you should either give yourself permissions to access that folder (not recommended), or just copy the font to a directory you own.
QUESTION
I'm sort of new to Web2py. I have a system that's working just fine, but I want to make an improvement regarding visualization. There's a couple of fields that use numbers (defined as double
in their respective define_table
methods) to represent currency, but I want them to also show with a separator for thousands, such as 183,403,293.34
. I checked some documentation, but I couldn't find a direct way to handle this form of customization, though I could be missing something.
Any suggestions regarding this? Cheers!
...ANSWER
Answered 2020-Jul-28 at 01:44First, if representing currency, you should use the decimal
field type rather than double
(some calculations using double
values may yield incorrect results due to the use of floating point representations internally). However, if using SQLite, there is no distinction between decimal
and double
, so in that case, you might want to multiply all values by 100 and instead store integers.
In any case, to display a given numeric value with thousands separators in Python, you can do:
QUESTION
I have found that using the 'Represents' functionality as described in http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer?search=lazy#Rendering-rows-using-represent slows things down quite a lot - more than doubles the time it takes to process some tables. This is a shame because this option makes it really easy to get human readable data from very simple table SELECTs.
I think this performance is to be expected since I assume it is issuing a SELECT for every record to get the Represents values. So I have 1 SELECT for my set of, say, 100 records and then there is another 100+ SELECTS to get the Represent values for the fields in one or more related tables as I access those records.
Any tips on how to improve the render() function performance? Or should I expect the render() option to be sluggish? Is the only alternative to build a query with the necessary joins in order to get the Represents data?
Thanks
...ANSWER
Answered 2020-Jul-15 at 20:43By default, reference
fields that refer to a related table with a format
attribute defined will get a represent
function that does indeed select the related record (and then applies the format
function/specification to the retrieved record), leading to the "N+1" query problem you have observed.
If you still want to make use of rows.render()
to apply the represent
functions of other types of fields that do not involve database selects, you can eliminate the problem for reference
fields by explicitly removing their default represent
attributes:
QUESTION
I wrote endpoint called foobar
in default.py
controller of web2py, it looks like
ANSWER
Answered 2020-Jul-04 at 05:34I resolved this problem by adding proper content-type
to payload
,
QUESTION
The web2py online book in Chapter 3 Overview says that in the scaffolding application, values for response.title
, response.meta.author
, etc, are set in the file models/menu.py
. While previous versions of Web2py did include the settings in menu.py
, in v.2.18.5
the default values are not set in this file. While some of the settings, such as response.meta.author
etc are defined in models/db.py
, response.title
and response.subtitle
could not be found in db.py
also. The online book does say that these can be defined in any model file. Can someone advise where these settings are now defined?
ANSWER
Answered 2020-Jun-24 at 11:56It appears that those items are no longer defined in the scaffolding app. The default layout simply using request.application
as the page title if request.title
is not defined. Feel free to define those items wherever, or not at all.
QUESTION
Following a tutorial, I have downloaded the Web2py Windows binaries. When I open web2py.exe, I get a quick command prompt screen. It immediately closes. I have uninstalled previous versions of Python, with no change. I also followed a recommendation from another post to create a .bat file to see the error. When I run it, I get the following:
...ANSWER
Answered 2020-Apr-18 at 04:35Try installing pythone 32 bit version and web2py source version.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install web2py
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page