Giter VIP home page Giter VIP logo

py4web's Introduction

Readme

web2py is a free open source full-stack framework for rapid development of fast, scalable, secure and portable database-driven web-based applications.

It is written and programmable in Python. LGPLv3 License

Learn more at http://web2py.com

Google App Engine deployment

cp examples/app.yaml ./
cp handlers/gaehandler.py ./

Then edit ./app.yaml and replace "yourappname" with yourappname.

Important reminder about this GIT repo

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.

git clone --recursive https://github.com/web2py/web2py.git

If you have an existing repository, the commands below need to be executed at least once:

git submodule update --init --recursive

PyDAL uses a separate stable release cycle to the rest of web2py. PyDAL releases will use a date-naming scheme similar to Ubuntu. Issues related to PyDAL should be reported to its separate repository.

Documentation (readthedocs.org)

Docs Status

Tests

Build Status MS Build Status Coverage Status

Installation Instructions

To start web2py there is NO NEED to install it. Just unzip and do:

python web2py.py

That's it!!!

web2py directory structure

project/
    README
    LICENSE
    VERSION                    > this web2py version
    web2py.py                  > the startup script
    anyserver.py               > to run with third party servers
    ...                        > other handlers and example files
    gluon/                     > the core libraries
        packages/              > web2py submodules
          dal/
        contrib/               > third party libraries
        tests/                 > unittests
    applications/              > are the apps
        admin/                 > web based IDE
            ...
        examples/              > examples, docs, links
            ...
        welcome/               > the scaffolding app (they all copy it)
            ABOUT
            LICENSE
            models/
            views/
            controllers/
            sessions/
            errors/
            cache/
            static/
            uploads/
            modules/
            cron/
            tests/
        ...                    > your own apps
    examples/                  > example config files, mv .. and customize
    extras/                    > other files which are required for building web2py
    scripts/                   > utility and installation scripts
    handlers/
        wsgihandler.py         > handler to connect to WSGI
        ...                    > handlers for Fast-CGI, SCGI, Gevent, etc
    site-packages/             > additional optional modules
    logs/                      > log files will go in there
    deposit/                   > a place where web2py stores apps temporarily

Issues?

Report issues at https://github.com/web2py/web2py/issues

py4web's People

Contributors

agavgavi avatar agrogers avatar ali96343 avatar carlos-da-costa avatar carloslopezmolina avatar carpaidea avatar cdb88 avatar ch-rigu avatar chbdetta avatar d3im avatar houdinihound avatar jpsteil avatar jsteil avatar karbiv avatar kevinkosterr avatar kkeller83 avatar lucadealfaro avatar macneiln avatar mauriziobrilli avatar mbelletti avatar mbfromok avatar mdipierro avatar misl6 avatar mrworm avatar nicozanf avatar paolopas avatar pepej avatar pirsch avatar tolgakonik avatar valq7711 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py4web's Issues

Git Merge: 12/26/2019 - _scaffold Error

Just merged git repo with my float using script to test #70 and I got the following error while trying to launch Py4Web:

Traceback (most recent call last):
File "D:\Dev\dashproj\dashproj\py4web\py4web\core.py", line 825, in import_app
module_name, init
File "", line 407, in _check_name_wrapper
File "", line 907, in load_module
File "", line 732, in load_module
File "", line 265, in _load_module_shim
File "", line 696, in _load
File "", line 677, in _load_unlocked
File "", line 728, in exec_module
File "", line 219, in call_with_frames_removed
File "apps_scaffold_init
.py", line 7, in
from . models import db
File "apps_scaffold\models.py", line 5, in
from .common import db, Field
File "apps_scaffold\common.py", line 102, in
from celery import Celery
ModuleNotFoundError: No module named 'celery'

Py4Web still suceeds in running Bottle and hosting.

PyDAL: Bulk Insert

Reading through the PyDAL docs and learning about how to insert and update data efficiently...

I see this:

py4web also provides a bulk_insert method:
>>> db.person.bulk_insert([{'name': 'Alex'}, {'name': 'John'}, {'name': 'Tim'}])

It further states:

It takes a list of dictionaries of fields to be inserted and performs multiple inserts at once

I have a dictionary (of dictionaries) full of entries like the following that I have since converted to a list of dictionaries to try and make this work:
{'EmployeeID': 'xxxxx', 'Department': 'XYZ Department', 'DisplayName': 'Person, Test', 'GivenName': 'Test', 'Surname': 'Person', 'IPPhone': '73509', 'telephoneNumber': '900-857-3509', 'mail': [email protected]', 'Attribute9': 'TUVWX'}

The issue I am running into is that the 'DisplayName': 'LastName, FirstName' breaks the import for each line and no fields import after this one.

Additionally, is there a way to pass a field map/list to this function? - (To map unlike fieldnames to db)

Error starting web3py: pydal has no attribute 'validators'

Just downloaded files a few minutes ago. :

Traceback (most recent call last):
File "web3py-start", line 6, in
main()
File "****/web3py/core.py", line 706, in main
args.password = pydal.validators.CRYPT()(getpass.getpass('Choose a one-time dashboad password: '))[0]
AttributeError: module 'pydal' has no attribute 'validators'

My pydal module is updated:
pip install pydal
Requirement already satisfied: pydal in /usr/lib/python3.7/site-packages (17.3)

By the way: thanks for web2py and web3py :-)

Shell support

Seen this repo a quite ago, but I just started testing out today for a upcoming project. (Currently I'm a "everyday" web2py user).

py4web seems to be very promising, and truly faster compared to web2py, so I'm looking forward to use it in production soon :) .

As a web2py user I'm used to have access to the "web2py shell" (./web2py.py -M -S app_name), which during the past few years was very useful during debugging or maintenance.

Is that an expected functionality in py4web ?

web3py start error

I try to start web3py, but getting below error. It ask for password, but after password, it throw error and quit. Please advice

Choose a one-time dashboad password:
Dashboard is at: http://127.0.0.1:8000/_dashboard
Traceback (most recent call last):
File "./web3py-start", line 6, in
main()
File "/opt/web3py/web3py-master/web3py/core.py", line 763, in main
Reloader.import_apps()
File "/opt/web3py/web3py-master/web3py/core.py", line 620, in import_apps
module = importlib.machinery.SourceFileLoader('apps', path).load_module()
File "", line 388, in _check_name_wrapper
File "", line 809, in load_module
File "", line 668, in load_module
File "", line 268, in _load_module_shim
File "", line 693, in _load
File "", line 673, in _load_unlocked
File "", line 661, in exec_module
File "", line 766, in get_code
File "", line 818, in get_data
FileNotFoundError: [Errno 2] No such file or directory: '/opt/web3py/web3py-master/apps/init.py'

DAL submodule not found

When i try to clone, a error is handling.

Cloning into 'web3py'...
remote: Counting objects: 759, done.
remote: Compressing objects: 100% (556/556), done.
remote: Total 759 (delta 156), reused 758 (delta 155), pack-reused 0
Receiving objects: 100% (759/759), 3.85 MiB | 2.04 MiB/s, done.
Resolving deltas: 100% (156/156), done.
Checking connectivity... done.
No submodule mapping found in .gitmodules for path 'packages/dal'

MySql Connection Error:

my /settings.py contains:
DB_URI = 'mysql://<dbuser>:<dbpass>@localhost/<table name>?set_encoding=utf8mb4_general_ci

I can't find a file / place calling MySQL with the 'utf8mb4_0900_ai_ci' setting to change it to my database anywhere!

How do I call MySQL with my preferred string if not using the string above?

Traceback (most recent call last):
File "C:\DevSDKs\Python\Python37\lib\site-packages\py4web\core.py", line 684, in import_apps importlib.reload(sys.modules[name])
File "C:\DevSDKs\Python\Python37\lib\importlib\__init__.py", line 169, in reload_bootstrap._exec(spec, module)
File "<frozen importlib._bootstrap>", line 630, in _exec
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "apps\GenMCV\models.py", line 9, in <module>
db = DAL(settings.DB_URI, folder=settings.DB_FOLDER, pool_size=settings.DB_POOL_SIZE)
File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 171, in __call__obj = super(MetaDAL, cls).__call__(*args, **kwargs)
File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 477, in __init__ "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
File "C:\Users\rhlin\AppData\Roaming\Python\Python37\site-packages\mysql\connector\connection_cext.py", line 472, in cmd_query
raw_as_string=raw_as_string)
_mysql_connector.MySQLInterfaceError: Unknown collation: 'utf8mb4_0900_ai_ci'

Wait, What?!? Reorganize _scaffold or examples

i think we might need to reorganize apps/_scaffold or apps/example.

I understand that there are probably multiple ways to implement and connect to databases, but we are providing scaffolding as a template or foundation for apps then modelling a different structure / method in the example (with no notation regarding alternative / best practices).

I will probably also propose notations or link to the docs (future friendly, one source to update) for the example files so that beginners like myself will have an easier time catching on to structure flow and the process of getting data into the system, updating, deleting, and displaying the data.

Common:

  • init.py: from . models import db

Uncommon:

  • examples/models.py:
db = DAL('sqlite://storage.db', folder=os.path.join(os.path.dirname(__file__), 'databases'))

vs

  • _scaffold/models.py: from . common import db, Field

  • _scaffold/common.py:

from . import settings
db = DAL(settings.DB_URI, 
         folder=settings.DB_FOLDER, 
         pool_size=settings.DB_POOL_SIZE)
  • _scaffold/settings.py:
# db settings
APP_FOLDER = os.path.dirname(__file__)
DB_FOLDER = os.path.join(APP_FOLDER, 'databases')
DB_URI = 'sqlite://storage.db'
DB_POOL_SIZE = 1

Py4web from Source: _scaffold app: Can't load database

Possibilities:

  • py4web is loading a folder into the dashboard that it shouldn't
  • there is a missing folder / file that is causing this issue
  • mutter, mutter things over my paygrade
Traceback (most recent call last):
  File "D:\Dev\GitHub\py4web\py4web\core.py", line 670, in import_apps
    module_name, init).load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Dev\GitHub\py4web\apps\_scaffold\__init__.py", line 6, in <module>
    from . models import db
  File "D:\Dev\GitHub\py4web\apps\_scaffold\models.py", line 8, in <module>
    db = DAL(settings.DB_URI, folder=settings.DB_FOLDER, pool_size=settings.DB_POOL_SIZE)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 171, in __call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 477, in __init__
    "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 457, in __init__
    self._adapter = adapter(**kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\__init__.py", line 39, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 369, in __init__
    super(SQLAdapter, self).__init__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 53, in __init__
    self.reconnect()
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\connection.py", line 154, in reconnect
    self.connection = self.connector()
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\sqlite.py", line 42, in connector
    return self.driver.Connection(self.dbpath, **self.driver_args)
sqlite3.OperationalError: unable to open database file

About reference fields

I was trying to make a CRUD with Publisher.It works but I have some problems with reference fields.Canยดt edit reference fields.I clicked the id and it displays all fields, but I cant edit references.

HowTo: Search all fields for value provided by input.

I took the example, connected it to my database, and if I type FieldName == ValueIWantToFind it will return the result I want, how do I take the search term and search all fields?

I have spent at least 5 hours trying to figure this out and appreciate the help.

examples give syntax error

Today I installed pi4web from source on a Windows 8.1 system. I have python 3.7 installed, I had to change the commands using python instead of python3 in the line
python3 -m pip install -r requirements.txt
an in the next line I had to prepend a "python " before the line
./py4web-start.py apps
then all worked apparently well.
After the installation I creates a new application from the scaffold and then I modified the init.py and then I saved the file. Immediately the icon of the examples button begun to blink in red.
The error messages are as follows:

Traceback (most recent call last):
File "C:\AC\py4web\py4web\core.py", line 839, in import_app
importlib.reload(sys.modules[name])
File "C:\Program Files\Python37\lib\importlib_init_.py", line 169, in reload
_bootstrap._exec(spec, module)
File "", line 630, in _exec
File "", line 728, in exec_module
File "", line 219, in _call_with_frames_removed
File "apps\examples\models.py", line 12, in
Field("job", requires=IS_NOT_EMPTY(), label=T('job')),
File "C:\Program Files\Python37\lib\site-packages\pydal\base.py", line 642, in define_table
raise SyntaxError("table already defined: %s" % tablename)
File "", line None
SyntaxError: table already defined: person

I deleted the installatoin and reinstalled the whole thing, all went well. Now I opened the init.py of the _dashboard application, made no changes and simply saved the file, I otained the same error in examples as before.
So it seems that the error does not lie in my modifications.
Kind regards.

Typo error

In the Installed Applications section for web3py Dashboard is a typo error: The option say Reaload Apps instead Reload Apps.

(Resolved) py4web: pip install: Launch Error - missing file 'py4web\apps\__init__.py'

IDE: Pycharm Community 2019.2
Python: 3.7.0

Started via: py4web-start apps

Traceback (most recent call last):
    File "C:\DevSDKs\Python\Python37\Scripts\py4web-start-script.py", line 11, in <module>
    load_entry_point('py4web==0.1.20190818.2', 'console_scripts', 'py4web-start')()
    File "C:\DevSDKs\Python\Python37\lib\site-packages\py4web\core.py", line 813, in main
    Reloader.import_apps()
    File "C:\DevSDKs\Python\Python37\lib\site-packages\py4web\core.py", line 658, in import_apps
    'apps', path).load_module()
    File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
    File "<frozen importlib._bootstrap_external>", line 907, in load_module
    File "<frozen importlib._bootstrap_external>", line 732, in load_module
    File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
    File "<frozen importlib._bootstrap>", line 696, in _load
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 724, in exec_module
    File "<frozen importlib._bootstrap_external>", line 859, in get_code
    File "<frozen importlib._bootstrap_external>", line 916, in get_data
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\Google Drive\\Development\\dashproj\\py4web\\apps\\__init__.py'

form.py _action="#" throws a 404

line 8 of form.py has the following "_action"

form = FORM(_method='POST',_action="#",_enctype='multipart/form-data')

I think the intention here is that the form is supposed to re-call itself but it is throwing me a 404 because it is looking for "app.name/static/#".

I have fixed it by replacing the "#" in _action with a request.url.

form = FORM(_method='POST',_action=request.url,_enctype='multipart/form-data')

I am not sure I fully understand why the "#" is not working on its own but will try to dig into further tomorrow.

Assets folder is missing from source version

During source version launch:
assets-folder: D:\Dev\GitHub\py4web\py4web\assets - Does not exist

During pip version launch:
assets-folder: C:\DevSDKs\Python\Python37\lib\site-packages\py4web\assets - Exists

_default app and URL helper

@actions are correctly routed in the _default app but when I try to use the URL helper to, for example, include an image on a page, the filepath is not being interpreted correctly.

URL('static', 'images/1.jpg') does not behave as expected in the _default app. In other apps, it works as expected.

I haven't been able to figure out the best way to fix this but I believe the solution is related to the following two areas of the core.py file:

365 --> prefix = '/%s/' % request.app_name if request.app_name != '_default' else '/'

485 --> path = ('/' if app_name == '_default' else '/%s/' % app_name) + self.path # the _default app has no prefix``

Py4web Docs: Causes browser freeze in Google Chrome

My Google Chrome: Version 77.0.3865.90 (Official Build)

I have been utilizing the pyDAL page of the docs heavily trying to build my code structure for database population.

I noticed that when I load the online (or locally hosted) docs (via browser link) that Chrome keeps freezing up every second or two for two to three seconds.

I am thinking this could be caused by the js refreshing / reloading when it isn't required. I have tried to troubleshoot, but am not familiar with the load process & syntax. Maybe a modification to load & display the content onLoad and onClick would resolve this?

Alternatively, I noticed that the MM code syntax isn't working properly <cough>tables, tables with cite(s)</cough>, it is possible that the issue is being caused by the js trying to interpret the mm and not completing the load. -- In order to assist, I spent about 2 hours trying to fix the markmin code, can't seem to get cites embedded in tables to work or get tables to display correctly in either browser.

I am able to load this in Firefox without issue (or it handles it in a way to prevent this).

Closed: "Table 'mydb.mytable1' doesn't exist" - XAMPP USB issue?

Ok, I have spent 2 hours trying to figure either what is causing this, or a way around this error.

What I want:

Match the functionality of /examples/models.py:
     - declare tables and then insert data from backups or online sources (when they are available)

What I am getting

Error (Part 1):

Traceback (most recent call last):
    File "D:\Dev\GitHub\MBfromOK\py4web\py4web\core.py", line 679, in import_apps
        module_name, init).load_module()
    File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
    File "<frozen importlib._bootstrap_external>", line 907, in load_module
    File "<frozen importlib._bootstrap_external>", line 732, in load_module
    File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
    File "<frozen importlib._bootstrap>", line 696, in _load
    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 728, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removeD

Relevant Part:

File "apps\testing\__init__.py", line 7, in <module>
    from . models import db
File "apps\testing\models.py", line 149, in <module>
    if not db(mydb.table1).count():

Error (Part (2):

    File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\objects.py", line 2395, in count
        return db._adapter.count(self.query, distinct)
    File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 791, in count
    self.execute(self._count(query, distinct))
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 413, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\MySQLdb\cursors.py", line 209, in execute
    res = self._query(query)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\MySQLdb\cursors.py", line 315, in _query
    db.query(q)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\MySQLdb\connections.py", line 226, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'mydb.table1' doesn't exist")

What I Have:

  • empty db
  • db user with permissions
  • completely empty table: table1
  • models.py containing

Code (Part 1):

db = DAL('mysql://test:testing@localhost/test?set_encoding=utf8mb4')

Code (Part 2):

db.define_table(
    'table1',
    Field('code', 'integer', required=True, unique=True),
    Field('name', 'string', length=256, required=True, requires='text'),
    Field('manager', 'string', length=256),
    Field('phone'),
    Field('address', 'string', length=256),
    Field('zip', 'string', length=256),
    Field('latitude', 'decimal(8,6)', required=True),
    Field('longitude', 'decimal(8,6)', required=True),
    Field('facilitytype', 'text', length=256),
    format='%(name)s'
)
db.commit()

Code (Part 3):

if not db(db.table1).count():
    # Call a script to retrieve the sites list - from both server and test
    print('Sites contains no data')
    if offlinetesting:
        print('\n\n\tTesting offline...\n\n')
        myfilepath = Path(Path(__file__).parent).as_posix()
        if not Path('.', 'sitelistgeo.csv').exists():
            print("sitelistgeo.csv missing")
        else:
            try:
                sitelist = bs(myfilepath)
            except Exception as Error:
                print(Error)
                pass
    else:
        # TODO Load content from an online source
        #  Should check if it has been updated first
        pass
    # After the script runs add the result to the sites table
    try:
        sitelist
    except NameError:
        sitelist = None
    finally:
        if not sitelist is None:
            for site in sitelist:
                if not site[0] == 'Code':
                    db.sites.insert(
                        code=site[0],
                        name=site[1],
                        manager=site[2],
                        phone=site[3],
                        address=site[4],
                        zip=site[5],
                        latitude=site[6],
                        longitude=site[7],
                        type=site[8]
                    )
            db.commit()
        else:
            if not Path('.', 'sitelistgeo.csv').exists() and offlinetesting:
                print('Offline Testing: True\n\tsitelistgeo.csv: File not found')

NOTE: Code 2 & 3 were originally back to back

What I tried so far:

  • Added a Try clause to detect if the table exists
  • Tried a while loop to declare the table until it was successfully created
  • Complete delete and reclone of py4web
  • Complete delete and wipe of MySql Database
  • Complete delete and wipe of MySql instance
  • Moved Code 3 to the bottom of models.py (after all the tables are declared)
  • Last attempt: Removed Code 3: - Works, but now the table has no data.

09/24/2019: Newest build breaks _scaffold:

Working before update:

Traceback (most recent call last):

  File "D:\Dev\GitHub\py4web\py4web\core.py", line 684, in import_apps
    importlib.reload(sys.modules[name])

  File "C:\DevSDKs\Python\Python37\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)

  File "<frozen importlib._bootstrap>", line 630, in _exec

  File "<frozen importlib._bootstrap_external>", line 728, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "apps\_scaffold\models.py", line 4, in <module>
    from . common import db, Field

ImportError: cannot import name 'Field' from 'apps._scaffold.common' (apps\_scaffold\common.py)

Mission and Vision of web3py

Hello,
i take a look at your code for web3py and i am pretty impressed of the new direction you want to take with this library.

i would like to invest some time for contribution but first of all, it is possible to clarify the vision of the project? i mean answering questions like what do we want to achieve or to do better than web2py?

i have many open questions like:

  1. How does the new architecture will look like?
  2. which standard modules have to be implemented? for example kind of SQLHTML using wue in Background, ....
  3. does web3py will also be backward compatible ? to all futures versions ?

here are some ideas but we need to define the vision before choosing to implement it:

  • i am a fan of microservices. will each apps be a kind of microservices ? if yes we can implement usecases like auth login, register, reset_password and so on ... as separated apps and create a kind of service binding who will fetch data from different service.

  • apps library as a Github repo with a possibility to install different apps just by running a command like: python3 web3py.py install http://.....app_name.git [tag, version] so it will be easier to develop custom apps that can be used for known cases. like cms, crm, erp, .... . this will help many users run web3py and easilly install needed apps like wordpress or joomla does.

  • admin app for creating small customizable application. an apps can just contains a python and html file. or maybe just a python file if someone need to buid micro api to connect to external services. this may be easier to implement in an online editor like in web2py.

  • global configurable routes with staging and prod environement. make it possible to install app. and then test it in a staging system only available on localhost or in a staging url Path. and with just on click in the admin app or as command, to make it available as usual in /app/... (as prod). so it will be easier to manage production apps

  • or some people will prefer to have different instance for each environement(1 server for staging, 1 for dev, 1 for prod, ...). in this case a command like python3 web3py.py deploy app_name --env [staging, prod, ...]. (or as action in the admin app.)
    [env] can literally be configured in an .ini file like this env_name IP:Port. this can be implemented through different channels like ssh/ftp, rsync, SCM(git, svn, ...) or even with an internal RESTAPI connection. which will allow 2 web3py instance to communicate. (may be this can also be used to auto sync session :-) )

my motivation is to build a library which will be easier for small to big businesses to use and manage their data. example: download a zip, unzip it no installation needed like web2py, install some app for your usecase, test it love it or change it easily, push it to your production server, enjoy and focus on your business.

what do you think about this ?

Fixed: Delete & Re-pull Source - Git merge: 12/26/2019 - _dashboard: "py4web_error" already exists

During launch:

"py4web_error" already exists

Traceback:

Traceback (most recent call last):
  File "D:\Dev\dashproj\dashproj\py4web\py4web\core.py", line 825, in import_app
    module_name, init
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "apps\_dashboard\__init__.py", line 24, in <module>
    error_storage = ErrorStorage()
  File "D:\Dev\dashproj\dashproj\py4web\py4web\core.py", line 700, in __init__
    Field("snapshot", "json"),
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 592, in define_table
    table = self.lazy_define_table(tablename, *fields, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 627, in lazy_define_table
    polymodel=polymodel)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 798, in create_table
    return self.migrator.create_table(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\migrator.py", line 282, in create_table
    self.adapter.create_sequence_and_triggers(query, table)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 881, in create_sequence_and_triggers
    self.execute(query)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\__init__.py", line 67, in wrap
    return f(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 413, in execute
    rv = self.cursor.execute(command, *args[1:], **kwargs)
sqlite3.OperationalError: table "py4web_error" already exists

Startup string:

python ./py4web-start.py --host localhost --port 8765 apps

py4web not starts

Hi,

I try to start py4web on my local machine by following steps as instructed as below:

git clone https://github.com/web2py/py4web.git
cd py4web
python3 -m pip install -r requirements.txt
./py4web-start apps

But unable to find py4web file after setup. I also try to run Makefile, but fails. I didnot install using through command "python3 -m pip install py4web".
Please provide complete step to make setup.

Regards
Narendra Kumar

dbadmin: Floats & Decimals blank

Data is in table, dbadmin columns blank: https://imgur.com/a/WnrtiDu

Added data as both a decimal and as a float.

Table Definition:

    db.define_table(
        'table1',
        Field('code', 'integer', required=True, unique=True),
        Field('name', 'string', length=256, required=True, requires='text'),
        Field('manager', 'string', length=256),
        Field('phone'),
        Field('address', 'string', length=256),
        Field('zip', 'string', length=256),
        Field('latitude', 'float(8,6)', required=True),
        Field('longitude', 'float(8,6)', required=True),
        Field('facilitytype', 'text', length=256),
        format='%(name)s'
    )

Data Insert code:

for site in sitelist:
    if not site[0] == 'Code':
        db.sites.insert(
        code=site[0],
        name=site[1],
        manager=site[2],
        phone=site[3],
        address=site[4],
        zip=site[5],
        latitude=float(site[6]),
        longitude=float(site[7]),
        type=site[8]
    )

TypeError: file must have 'read', 'readinto' and 'readline' attributes

I encounter the same errors for many times, pip install(then I try to install from source and succeed), realod apps in the dashboard, what may be the problem?

/pydal/migrator.py", line 300, in create_table
    sql_fields_old = pickle.load(tfile)
TypeError: file must have 'read', 'readinto' and 'readline' attributes

I use python 3.8 on macOS Catalina. Thanks!

Py4web from Source: examples app: Can't load database

Possibilities:

  • py4web is loading a folder into the dashboard that it shouldn't
  • there is a missing folder / file that is causing this issue
  • mutter, mutter things over my paygrade
Traceback (most recent call last):
  File "D:\Dev\GitHub\py4web\py4web\core.py", line 670, in import_apps
    module_name, init).load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "D:\Dev\GitHub\py4web\apps\examples\__init__.py", line 7, in <module>
    db = DAL('sqlite://test', folder=os.path.join(os.path.dirname(__file__), 'databases'))
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 171, in __call__
    obj = super(MetaDAL, cls).__call__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 477, in __init__
    "Failure to connect, tried %d times:\n%s" % (attempts, tb)
RuntimeError: Failure to connect, tried 5 times:
Traceback (most recent call last):
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 457, in __init__
    self._adapter = adapter(**kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\__init__.py", line 39, in __call__
    obj = super(AdapterMeta, cls).__call__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 369, in __init__
    super(SQLAdapter, self).__init__(*args, **kwargs)
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\base.py", line 53, in __init__
    self.reconnect()
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\connection.py", line 154, in reconnect
    self.connection = self.connector()
  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\adapters\sqlite.py", line 42, in connector
    return self.driver.Connection(self.dbpath, **self.driver_args)
sqlite3.OperationalError: unable to open database file

problems with ldap

I created a new py4web app using the dashboard. The scaffold template created the skeleton of the new app. Ok.

In the file settings.py, line 33, says:
LDAP_SETTING={
It would must be:
LDAP_SETTINGS={

Corrected this mispelling, the next error:
File "/home/advh67/py4web/apps/mynewapp/common.py", line 47, in
auth.register_plugin(LDAPPlugin(**LDAP_SETTINGS))
NameError: name 'LDAP_SETTINGS' is not defined

would must be(?):
auth.register_plugin(LDAPPlugin(**settings.LDAP_SETTINGS))

Once corrected, the initialization fails again:

File "/home/advh67/py4web/apps/mynewapp/common.py", line 47, in
auth.register_plugin(LDAPPlugin(**settings.LDAP_SETTINGS))
File "/usr/lib/python3.7/site-packages/py4web/utils/auth.py", line 106, in register_plugin
self.plugins[plugin.name] = plugin
AttributeError: 'LDAPPlugin' object has no attribute 'name'

I am stuck.

Py4web was installed using: python3 -m pip install --upgrade py4web
an launched by typing: py4web-start apps
as told in documentation.

My folder /home/advh67/py4web is empty of files. It only contains the apps folder.

09/24/2019: Newest build - Custom App: table already defined: auth_user_tag_groups

Worked before update, built app with _scaffold template

Traceback (most recent call last):

  File "D:\Dev\GitHub\py4web\py4web\core.py", line 684, in import_apps
    importlib.reload(sys.modules[name])

  File "C:\DevSDKs\Python\Python37\lib\importlib\__init__.py", line 169, in reload
    _bootstrap._exec(spec, module)

  File "<frozen importlib._bootstrap>", line 630, in _exec

  File "<frozen importlib._bootstrap_external>", line 728, in exec_module

  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

  File "apps\GenMCV\common.py", line 39, in <module>

    groups = Tags(db.auth_user, 'groups')

  File "D:\Dev\GitHub\py4web\py4web\utils\tags.py", line 14, in __init__

    Field('record_id', table))

  File "C:\DevSDKs\Python\Python37\lib\site-packages\pydal\base.py", line 581, in define_table

    raise SyntaxError('table already defined: %s' % tablename)

  File "<string>", line None

SyntaxError: table already defined: auth_user_tag_groups

Try from Source: Make from Windows?

Just tried to clone this repo from windows with Github desktop, how should windows developers take advantage of source option?

The highest recommendation on Google is msysGit which was superseded by Git for Windows 2.x

Reloader bug

Reloader reloads foreign modules (from other apps) if application names start with the same letters. It makes a terrible mess in action/routes/sessions. I tore a lot of my hair out to catch this

names = [name for name in sys.modules if name.startswith(module_name)]

reloader_bug

Typo on Web Page "Creating your first app"

Sample init.py from webpage here:

import datetime
from py4web import action

@action('index')
def page():
    return "hello, now is %s" % datetime.datime.now()

Should be datetime.datetime.now()

dashboard password not working anymore

When entering a password in the frontend the following error appears:
ERROR:root:Traceback (most recent call last):
File "/home/wouter/.local/lib/python3.6/site-packages/py4web/core.py", line 469, in wrapper
ret = func(*func_args, **func_kwargs)
File "/home/wouter/.local/lib/python3.6/site-packages/py4web/core.py", line 435, in wrapper
ret = func(*args, **kwargs)
File "apps/_dashboard/init.py", line 56, in login
valid = password and CRYPT()(password)[0] == os.environ['PY4WEB_PASSWORD']
File "/usr/lib/python3.6/os.py", line 669, in getitem
raise KeyError(key) from None
KeyError: 'PY4WEB_PASSWORD'

How to set server own email to send verification link for newly registered user?

Hi, we were running a py4web app named bipolarai under this domain bipolar.ai. We are running it with uwsgi and Nginx. I was finding the section to send the user registration verification link. Because users are getting 'verification pending' alert when they are going to log in after a successful registration. How I can provide them the verification link? Please help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.