add docstrings

develop
gwen 2 years ago
parent a74dd31afb
commit 0aadc12ee7

@ -4,6 +4,8 @@ Mongodb storage init
- collections creation
- helper queries
TODO : maybe put the mongodb connector into the flask app object
with the pymongo library.
"""
import urllib.parse
@ -12,14 +14,19 @@ from pymongo import MongoClient
from .config import dbadmin, dbpassword, server_ip
# TODO : maybe put the mongodb connector in the flask app object
# ______________________________________________________________________________
# database connexion
def database_connexion(username, password, server_ip):
username = urllib.parse.quote_plus(dbadmin)
password = urllib.parse.quote_plus(dbpassword)
dbclient = MongoClient(f'mongodb://{username}:{password}@{server_ip}:27017')
# database
actesdb = dbclient["actesdb"]
return actesdb
actesdb = database_connexion(dbadmin, dbpassword, server_ip)
# collections
housecol = actesdb["house"]
# the acte collection is the most important collection

@ -1,3 +1,23 @@
"""main flask app routes
There are two types of routes, first the static routes :
- /
- /about
- /actes
- /contact
- /privacy
- /termsofservice
Then the dynamic routes :
- /actes
- /actes/<house>
- /actes/<house>/<prince>
- /acte/<house>/<prince>/<dateitem>
- /geoloc
"""
import typing as t
@ -54,13 +74,13 @@ def actes(house):
# prince_code = act['prince_code'].capitalize()
# if (prince_name, prince_code) not in princes:
# princes.append((prince_name, prince_code))
# sample result:
# [('Louis II de Bourbon', 'lo_ii'), ('Anne Dauphine', 'ann_i'), ('Agnès de Bourgogne', 'agn_i'), ('Charles Ier de Bourbon', 'ch_i')]
# [('Agnès de Bourgogne', 'agn_i'), ('Anne Dauphine', 'ann_i'), ('Charles Ier de Bourbon', 'ch_i'), ('Louis II de Bourbon', 'lo_ii')
princes = princes_in_houses[house]
# TODO : modify the jinja template and suppress this line
# TODO : modify the jinja template's design in order to suppress this ugly line
princes = [(prc['prince_name'], prc['prince_code']) for prc in princes]
# [('Agnès de Bourgogne', 'agn_i'), ('Anne Dauphine', 'ann_i'), ('Charles Ier de Bourbon', 'ch_i'), ('Louis II de Bourbon', 'lo_ii')
return render_template("corpus.html", house=house.capitalize(), princes=princes)

Loading…
Cancel
Save