Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cabalamat/frambozenapp
Showcasing my Bozen library, which includes a MongoDB ORM, Form library, and web utilities
https://github.com/cabalamat/frambozenapp
html mongodb python36
Last synced: about 2 months ago
JSON representation
Showcasing my Bozen library, which includes a MongoDB ORM, Form library, and web utilities
- Host: GitHub
- URL: https://github.com/cabalamat/frambozenapp
- Owner: cabalamat
- Created: 2018-11-13T09:11:35.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-03-20T04:40:52.000Z (almost 4 years ago)
- Last Synced: 2023-05-23T00:55:13.097Z (over 1 year ago)
- Topics: html, mongodb, python36
- Language: Python
- Homepage:
- Size: 2.74 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
Awesome Lists containing this project
README
# Frambozenapp
![Frambozen Logo](doc/frambozen_logo.png)
**Frambozenapp** is a Python web application that showcases the
**Bozen** library.## About Bozen
Bozen is a library that makes web development with Flask and MongoDB
faster. (I'm using it in my
[MeowCat](https://github.com/cabalamat/meowcat2) blogging platform.)Bozen is:
* a Form library: renders and handles HTML forms
* a MongoDB ORM (terchnically a MongoDB ODM, since MongoDB isn't a
relational database)
* several utility functions for web developmentThe most important classes in Bozen are:
* **FormDoc**, which handles HTML forms
* **MonDoc**, a subclass of `FormDoc` which knows how to get data into and out of a MongoDB database
* the **FieldInfo** classes. Every field has an instance of a subclass of FieldInfo describing what data type it is and how it behaves in a form.Other Bozen features:
* For a MonDoc, automatically generated **autopages** can perform BREAD
(Browse, Read, Edit, Add, Delete) functionality for it.
* The **Paginator** class enables a table to be paginated so that only a
certain number of rows appear on each page.## Installation
Requirements: Python 3.6, MongoDB, Git (to clone repository).
To start, first clone the repository locally.
$ git clone [email protected]:cabalamat/frambozenapp.git
$ cd frambozenapp
Create a virtual environment called `v3`:$ python3 -m venv v3
Go into your virtual environment:$ . v3/bin/activate
Install the requirements:$ pip install -r requirements.txt
Finally, go into the `app/` directory and run the program. The
`--debug` flag denotes that you are running it in debugging mode.
$ cd app
$ python main.py --debugNow you can point your web browser at to
view the site.## Documentation
Documentation is available in the `./doc/` directory. It's in the
extended markdown format that
[CatWiki](https://github.com/cabalamat/catwiki) uses
(and was created in CatWiki), so is best viewed with CatWiki.## Screenshots
**Test Form** shows some of the form controls:
![](doc/test_form.png)
The **Foos** page shows a list of *Foos* (Foo being a collection
in the database). Note that the pagination is handled by Bozen.![](doc/foos.png)
The **Foo** page shows a single *Foo*, and allows you to edit its
fields. The form is automatically denerated from the database schema
(in `foo.py`):```py
DRINK_CHOICES = [
('beer', "Beer"),
('beer-lager', "Lager"),
('beer-frambozen', "Frambozen"),
('wine', "Wine"),
('spirits-whisky', "Whisky"),
('spirits-gin', "Gin"),
]
FRUIT_CHOICES = [
('apple', "Apple"),
('banana', "Banana"),
('strawberry', "Strawberry"),
('raspberry', "Raspberry"),
]class Foo(MonDoc):
name = StrField()
description = TextAreaField(monospaced=True)
aNumber = IntField(minValue=0, maxValue=100)
minSpeed = FloatField(title="Minimum Speed, mph", minValue=0.0)
maxSpeed = FloatField(title="Maximim Speed, mph", minValue=0.0)
favouriteDrink = ChoiceField(choices=DRINK_CHOICES,
showNull=True, allowNull=True)
fruitsLiked = MultiChoiceField(choices=FRUIT_CHOICES,
desc="tick all fruits this person likes")
tickyBox = BoolField()
aDate = DateField()
lastSaved = DateTimeField(desc="when this foo was last saved",
readOnly=True)
aDateTime = DateTimeField(title="A Date and Time")
anything = ObjectField(desc="can contain anything",
default=["any", "thing"])
favouriteBook = FK(models.Book, allowNull=True, showNull=True)
```![](doc/foo.png)
Given the database schema for `Foo` above, the `/foos` and `/foo`
pages could have been automatically generated by this one line:```py
Foo.autopages()
```(This wasn't done in the Foo example, for didactic purposes).