Fixes in documentation

This commit is contained in:
absurdo 2023-11-04 21:15:44 +01:00
parent cfb70403c1
commit dc58175760
13 changed files with 119 additions and 113 deletions

View file

@ -16,6 +16,9 @@ except:
#sys.exit(1) #sys.exit(1)
pass pass
"""Command line utility for extract I18n.lang strings from html templates and .py files
"""
pattern=re.compile('^\w+\.(py|html|phtml|js)$') pattern=re.compile('^\w+\.(py|html|phtml|js)$')
ignored=re.compile('^[__|\.].*$') ignored=re.compile('^[__|\.].*$')
@ -26,6 +29,8 @@ lang_t=re.compile("\${lang\('(.*?)',\s+'(.*?)',\s+'(.*?)'\)\}")
tmp_lang={} tmp_lang={}
def start(): def start():
"""Function for extract I18n.lang strings from html templates and .py files using regular expressions
"""
global lang_p global lang_p
global lang_t global lang_t

View file

@ -1,4 +1,9 @@
# Variable base for admin modules # Variable base for admin modules
"""Variables for control admin modules for admin module
"""
config_admin=[] config_admin=[]
"""list: List for save the differente admin configurations from paramecio2 modules
"""

View file

@ -81,7 +81,7 @@ def format_timedata(time):
time (str): A YYYYMMDDHHmmss string for get datetime components from there. time (str): A YYYYMMDDHHmmss string for get datetime components from there.
Returns: Returns:
list: A dict with datetime components (year, month, day, hour, minute, second). list (list): A dict with datetime components (year, month, day, hour, minute, second).
""" """
@ -131,7 +131,7 @@ def checkdatetime(y, m, d, h, mi, s):
s (int): seconds s (int): seconds
Returns: Returns:
bool: If values are correct, return True, otherwise return False bool (bool): If values are correct, return True, otherwise return False
""" """
@ -153,7 +153,7 @@ def now(utc=False, tz=''):
tz (str, optional): Timezone name, example: Europe/Madrid. If set the datetime is returned in the timezone selected tz (str, optional): Timezone name, example: Europe/Madrid. If set the datetime is returned in the timezone selected
Returns: Returns:
str: Return actual datetime datetime (str): Return actual datetime
""" """
@ -180,7 +180,7 @@ def today(utc=False,tz=''):
tz (str, optional): Timezone name, example: Europe/Madrid. If set the date is returned in the timezone selected tz (str, optional): Timezone name, example: Europe/Madrid. If set the date is returned in the timezone selected
Returns: Returns:
str: Return actual date with 00:00:00 how time datetime (str): Return actual date with 00:00:00 how time
""" """
@ -197,7 +197,7 @@ def obtain_timestamp(timeform):
Returns: Returns:
int: datetime in timestamp format Timestamp (int): datetime in timestamp format
""" """
@ -225,7 +225,7 @@ def timestamp_to_datetime(timestamp, sql_format_time=sql_format_time):
timestamp (int): The timestamp for convert timestamp (int): The timestamp for convert
Returns: Returns:
str: Datetime in YYYYMMDDHHmmss format datetime (str): Datetime in YYYYMMDDHHmmss format
""" """
@ -242,7 +242,7 @@ def timestamp_to_datetime_local(timestamp, tz='', sql_format_time=sql_format_tim
Returns: Returns:
str: Datetime in YYYYMMDDHHmmss format in selected timezone datetime datetime (str): Datetime in YYYYMMDDHHmmss format in selected timezone datetime
""" """
@ -264,7 +264,7 @@ def format_datetime(format_time, timeform, func_utc_return):
func_utc_return (function): A function used for get the datetime. func_utc_return (function): A function used for get the datetime.
Returns: Returns:
If timestamp is False, return False, if timestamp is valid, return the datetime formatted datetime (str): If timestamp is False, return False, if timestamp is valid, return the datetime formatted
""" """
@ -293,7 +293,7 @@ def local_to_gmt(timeform, sql_format_time=sql_format_time):
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here. sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
@ -312,7 +312,7 @@ def gmt_to_local(timeform, sql_format_time=sql_format_time):
sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here. sql_format_time (str, optional): by default, the format is YYYYMMDDHHmmss, you can put other formatted str formats for date, here.
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
@ -326,7 +326,7 @@ def format_time(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
""" """
@ -340,7 +340,7 @@ def format_date(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
""" """
return format_datetime(format_date_txt, timeform, sum_utc) return format_datetime(format_date_txt, timeform, sum_utc)
@ -353,7 +353,7 @@ def format_fulldate(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
""" """
return format_datetime(format_date_txt+' '+format_time_txt, timeform, sum_utc) return format_datetime(format_date_txt+' '+format_time_txt, timeform, sum_utc)
@ -366,7 +366,7 @@ def format_local_time(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
return format_datetime(format_time_txt, timeform, no_utc) return format_datetime(format_time_txt, timeform, no_utc)
@ -379,7 +379,7 @@ def format_local_date(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
return format_datetime(format_date_txt, timeform, no_utc) return format_datetime(format_date_txt, timeform, no_utc)
@ -392,7 +392,7 @@ def format_local_fulldate(timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
return format_datetime(format_date_txt+' '+format_time_txt, timeform, no_utc) return format_datetime(format_date_txt+' '+format_time_txt, timeform, no_utc)
@ -405,7 +405,7 @@ def format_strtime(strtime, timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted in UTC
""" """
return format_datetime(strtime, timeform, sum_utc) return format_datetime(strtime, timeform, sum_utc)
@ -418,7 +418,7 @@ def format_local_strtime(strtime, timeform):
timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format timeform (str): datetime in YYYYMMDDHHmmss format to convert to new format
Returns: Returns:
If timeform is False, return False, if timeform is valid, return the datetime formatted datetime (str): If timeform is False, return False, if timeform is valid, return the datetime formatted
""" """
return format_datetime(strtime, timeform, no_utc) return format_datetime(strtime, timeform, no_utc)
@ -434,7 +434,7 @@ def sum_utc(timestamp, tz=''):
tz (str): Timezone of timestamp tz (str): Timezone of timestamp
Returns: Returns:
Return arrow object with new timezone selected datetime (str): Return arrow object with new timezone selected
""" """
#offset=time.altzone #offset=time.altzone
@ -459,7 +459,7 @@ def substract_utc(timestamp, tz=''):
tz (str): Timezone of timestamp tz (str): Timezone of timestamp
Returns: Returns:
Return arrow object with UTC timezone selected datetime (str): Return arrow object with UTC timezone selected
""" """
#offset=time.altzone #offset=time.altzone
@ -487,7 +487,7 @@ def no_utc(timestamp):
timestamp (int): The timestamp for convert in UTC timezone timestamp (int): The timestamp for convert in UTC timezone
Returns: Returns:
Return arrow object based in timestamp value datetime (str): Return arrow object based in timestamp value
""" """
@ -550,7 +550,7 @@ class TimeClass:
num_months (int): Number of months to add num_months (int): Number of months to add
Returns: Returns:
New added datetime datetime (str): New added datetime
""" """
m=self.t.shift(months=+num_months) m=self.t.shift(months=+num_months)
@ -564,7 +564,7 @@ class TimeClass:
num_months (int): Number of months to substract num_months (int): Number of months to substract
Returns: Returns:
New substracted datetime datetime (str): New substracted datetime
""" """
m=self.t.shift(months=-num_months) m=self.t.shift(months=-num_months)
@ -578,7 +578,7 @@ class TimeClass:
num_days (int): Number of days to add num_days (int): Number of days to add
Returns: Returns:
New added datetime datetime (str): New added datetime
""" """
m=self.t.shift(days=+num_days) m=self.t.shift(days=+num_days)
@ -592,7 +592,7 @@ class TimeClass:
num_days (int): Number of days to substract num_days (int): Number of days to substract
Returns: Returns:
New substracted datetime datetime (str): New substracted datetime
""" """
@ -607,7 +607,7 @@ class TimeClass:
num_years (int): Number of years to add num_years (int): Number of years to add
Returns: Returns:
New added datetime datetime (str): New added datetime
""" """
m=self.t.shift(years=+num_years) m=self.t.shift(years=+num_years)
@ -621,7 +621,7 @@ class TimeClass:
num_years (int): Number of years to substract num_years (int): Number of years to substract
Returns: Returns:
New substracted datetime datetime (str): New substracted datetime
""" """
m=self.t.shift(years=-num_years) m=self.t.shift(years=-num_years)
@ -635,7 +635,7 @@ class TimeClass:
num_hours (int): Number of hours to add num_hours (int): Number of hours to add
Returns: Returns:
New added datetime datetime (str): New added datetime
""" """
m=self.t.shift(hours=+num_hours) m=self.t.shift(hours=+num_hours)
@ -649,7 +649,7 @@ class TimeClass:
num_hours (int): Number of hours to substract num_hours (int): Number of hours to substract
Returns: Returns:
New substracted datetime datetime (str): New substracted datetime
""" """
m=self.t.shift(hours=-num_hours) m=self.t.shift(hours=-num_hours)
@ -660,7 +660,7 @@ class TimeClass:
"""Method for get datetime formatted using format_date_full attribute """Method for get datetime formatted using format_date_full attribute
Returns: Returns:
Datetime formatted with format_date_full attribute datetime (str): Datetime formatted with format_date_full attribute
""" """
return self.t.format(self.format_date_full) return self.t.format(self.format_date_full)
@ -669,7 +669,7 @@ class TimeClass:
"""Method for get datetime formatted using format_time attribute """Method for get datetime formatted using format_time attribute
Returns: Returns:
Datetime formatted with format_time attribute datetime (str): Datetime formatted with format_time attribute
""" """
return self.t.format(self.format_time) return self.t.format(self.format_time)
@ -699,7 +699,7 @@ class TimeClass:
Returns: Returns:
Actual datetime formatted in YYYYMMDDHHmmss format. datetime (str): Actual datetime formatted in YYYYMMDDHHmmss format.
""" """
if not utc: if not utc:
@ -719,7 +719,7 @@ class TimeClass:
Returns: Returns:
Actual datetime formatted in YYYYMMDD000000 format. datetime (str): Actual datetime formatted in YYYYMMDD000000 format.
""" """
if utc: if utc:
@ -738,7 +738,7 @@ class TimeClass:
Returns: Returns:
Datetime in YYYYMMDDHHmmss format. datetime (str): Datetime in YYYYMMDDHHmmss format.
""" """
return arrow.get(timestamp).format(sql_format_time) return arrow.get(timestamp).format(sql_format_time)
@ -752,7 +752,7 @@ class TimeClass:
Returns: Returns:
Datetime in YYYYMMDDHHmmss format.If timeform is incorrect, return False datetime (str): Datetime in YYYYMMDDHHmmss format.If timeform is incorrect, return False
""" """
y, m, d, h, mi, s=format_timedata(timeform) y, m, d, h, mi, s=format_timedata(timeform)
@ -776,7 +776,7 @@ class TimeClass:
Returns: Returns:
Datetime in strtime format.If timeform is incorrect, return False datetime (str): Datetime in strtime format.If timeform is incorrect, return False
""" """

View file

@ -139,7 +139,7 @@ class DoubleField(FloatField):
return 'DOUBLE NOT NULL DEFAULT "0"' return 'DOUBLE NOT NULL DEFAULT "0"'
class CharField(PhangoField): class CharField(PhangoField):
"""Simple alias for PhangoField for clarify that """ """Simple alias for PhangoField"""
pass pass
@ -238,12 +238,12 @@ class ForeignKeyField(IntegerField):
""" """
Args: Args:
name (str): Name of field name (str): Name of field
related_table(WebModel): The table-model related with this foreign key related_table (WebModel): The table-model related with this foreign key
size (int): The size of the new field in database. By default 11. size (int): The size of the new field in database. By default 11.
required (bool): Boolean for define if field is required or not required (bool): Boolean for define if field is required or not
identifier_field (str): The Id field name from related table identifier_field (str): The Id field name from related table
named_field (str): The field from related table used for identify the row seleted from related table named_field (str): The field from related table used for identify the row seleted from related table
select_field (list): A series of fields names from related select_fields (list): A series of fields names from related
""" """
super(ForeignKeyField, self).__init__(name, size, required) super(ForeignKeyField, self).__init__(name, size, required)
@ -292,7 +292,6 @@ class BooleanField(IntegerField):
""" """
Args: Args:
name (str): Name of field name (str): Name of field
related_table(str): The table related with this foreign key
size (int): The size of the new field in database. By default 11. size (int): The size of the new field in database. By default 11.
""" """

View file

@ -141,7 +141,7 @@ class SelectForm(BaseForm):
def __init__(self, name, value, elements=OrderedDict()): def __init__(self, name, value, elements=OrderedDict()):
""" """
Args: Args:
ame (str): The html name for this form name (str): The html name for this form
value (str): The default value of this html form value (str): The default value of this html form
elements (OrderedDict): An ordered dict with the keys(the form value) and text label. Example, if you have a OrderedDict how {'0': 'Value selected'} in a html select form you have the next result: <select name="name"><option value="0">Value selected</option></selected> elements (OrderedDict): An ordered dict with the keys(the form value) and text label. Example, if you have a OrderedDict how {'0': 'Value selected'} in a html select form you have the next result: <select name="name"><option value="0">Value selected</option></selected>
""" """
@ -172,7 +172,6 @@ class SelectModelForm(SelectForm):
Args: Args:
name (str): The html name for this form name (str): The html name for this form
value (str): The default value of this html form. value (str): The default value of this html form.
arr_select (OrderedDict): Used for save the data from the webmodel
model (WebModel): The webmodel used for get the data for arr_select model (WebModel): The webmodel used for get the data for arr_select
field_name (str): The field used for get the name of every option in select field_name (str): The field used for get the name of every option in select
field_value (str): The field used for get the value of every option in select field_value (str): The field used for get the value of every option in select

View file

@ -741,7 +741,8 @@ class WebModel:
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
Return cursor db for get data using loops or other if operation is successful, if not, return False. false (bool): If return false, the db connection is down.
sql_cursor (cursor): Return cursor db for get data using loops or other if operation is successful, if not, return False.
""" """
@ -865,7 +866,7 @@ class WebModel:
cursor (Db cursor): A typical db cursor of python sql interface standard. cursor (Db cursor): A typical db cursor of python sql interface standard.
Returns: Returns:
dict: Return a dictionary with the row selected. row (dict): Return a dictionary with the row selected.
""" """
@ -906,7 +907,7 @@ class WebModel:
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
dict: Returns dict with the row values. row (dict): Returns dict with the row values.
""" """
self.conditions=['WHERE `'+self.name+'`.`'+self.name_field_id+'`=%s', [id]] self.conditions=['WHERE `'+self.name+'`.`'+self.name_field_id+'`=%s', [id]]
@ -936,7 +937,7 @@ class WebModel:
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
dict: Returns dict with the row values. row (dict): Returns dict with the row values.
""" """
self.limit="limit "+str(begin)+", 1" self.limit="limit "+str(begin)+", 1"
@ -963,7 +964,7 @@ class WebModel:
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
dict: Returns dict with the row values. row_values (dict): Returns dict with the row values.
""" """
@ -1013,7 +1014,7 @@ class WebModel:
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
dict: Returns dict with the row values. row (dict): Returns dict with the row values.
""" """
if integer: if integer:
@ -1064,12 +1065,11 @@ class WebModel:
"""Method for get a typical sql count using conditions """Method for get a typical sql count using conditions
Args: Args:
Args: field_to_count (str): The field
fields_selected (dict): A list with the name of the fields how defined in PhangoField.
raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select. raw_query (bool): If True, if foreignkeyfields exists, are not selected. If False, foreignkeyfields are selected too if foreignkeyfield are in arr_select.
Returns: Returns:
int: Returns the number of elements selected. num_elecments (int): Returns the number of elements selected.
""" """
# Connect to db # Connect to db
@ -1120,7 +1120,7 @@ class WebModel:
"""Method for delete a series of rows using conditions """Method for delete a series of rows using conditions
Returns: Returns:
bool: If delete is successfully, return True, if not, return False. bool (bool): If delete is successfully, return True, if not, return False.
""" """
#self.connect_to_db() #self.connect_to_db()
@ -1166,7 +1166,7 @@ class WebModel:
in_list (list): List with numbers items. in_list (list): List with numbers items.
Returns: Returns:
string with (1,2,3) sql sentence filtered. sql_filtered (str): with (1,2,3) sql sentence filtered.
""" """
@ -1185,7 +1185,7 @@ class WebModel:
in_list (list): List with value items. in_list (list): List with value items.
Returns: Returns:
string with (value1, value2, value3) sql sentence filtered. sql_filtered (str): (value1, value2, value3) sql sentence filtered.
""" """
for x in range(0, len(in_list)): for x in range(0, len(in_list)):
@ -1359,7 +1359,7 @@ class WebModel:
"""Method for drop a table based in this model """Method for drop a table based in this model
Returns: Returns:
Return True if table was dropped successfully, false if table can't be dropped. sql_str (str): Return the sql query for drop the table represented by this model
""" """
return self.query('DROP TABLE '+self.name, [], self.connection_id) return self.query('DROP TABLE '+self.name, [], self.connection_id)
@ -1381,8 +1381,10 @@ class WebModel:
errors_set (str): If insert value, the errors are set for insert sql statement, if update value, then the errors are set for update sql statement. errors_set (str): If insert value, the errors are set for insert sql statement, if update value, then the errors are set for update sql statement.
Returns: Returns:
Return False if checking is wrong. If not False returns a tuple with fields filtered, original values as values and values filtered how update_values wrong (bool): Return False if checking is wrong. If not False returns a tuple with fields filtered, original values as values and values filtered how update_values
return (fields, values, update_values) fields (list): list with fields
values (dict): dict with values
update_values (dict): dict with updated values with checking
""" """
fields=[] fields=[]
@ -1579,7 +1581,7 @@ class WebModel:
"""Get all errors of model last operation. """Get all errors of model last operation.
Returns: Returns:
str: A string with all errors. error_txt (str): A string with all errors.
""" """
arr_error=[] arr_error=[]
@ -1604,7 +1606,7 @@ class WebModel:
"""Get all errors and save in dictionary """Get all errors and save in dictionary
Returns: Returns:
dict: Return a dict where the key is the field where the error exists and value is the error text. errors (dict): Return a dict where the key is the field where the error exists and value is the error text.
""" """
arr_error= {} arr_error= {}
@ -1666,7 +1668,7 @@ class WebModel:
"""Prepare a dict with values using fields keys how base """Prepare a dict with values using fields keys how base
Returns: Returns:
dict: Return a dict with values without checking anything. post (dict): Return a dict with values without checking anything.
""" """
for k in self.fields.keys(): for k in self.fields.keys():

View file

@ -21,7 +21,7 @@ def pass_values_to_form(post, arr_form, yes_error=True, pass_values=True):
pass_values (bool): Pass default values or values from post dict to arr_form dict items pass_values (bool): Pass default values or values from post dict to arr_form dict items
Returns: Returns:
dict: Return arr_form dict with checked values from post dict. arr_form (dict): Return arr_form dict with checked values from post dict.
""" """
@ -76,7 +76,8 @@ class CheckForm():
arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict. arr_form (dict): Dict composed by a series or forms objects. The keys need to be equal to keys of post dict.
Returns: Returns:
dict: Return arr_form dict with checked values from post dict. post (dict): Return post dict with values checked
arr_form (dict): Return arr_form with errors and values.
""" """
@ -104,10 +105,10 @@ def check_form(post, arr_form, sufix_form='_error'):
sufix_form (str): Define the sufix of error_form keys sufix_form (str): Define the sufix of error_form keys
Returns: Returns:
bool: Return False if not errors in checking, if errors return True error (bool): Return False if not errors in checking, if errors return True
dict: A dict containing the errors in form fields. error_form (dict): A dict containing the errors in form fields.
post: Sanitized values post (dict): Sanitized values
arr_form: arr_form with errors and values. arr_form (dict): arr_form with errors and values.
""" """
@ -143,7 +144,7 @@ def show_form(post, arr_form, t, yes_error=True, pass_values=True, modelform_tpl
Returns: Returns:
An html string with the generated form. template (str): An html string with the generated form.
""" """
@ -187,7 +188,7 @@ def csrf_token(token_id='csrf_token'):
token_id (str): Name of the html hide form token_id (str): Name of the html hide form
Returns: Returns:
Return html input hidden with csrf token saved in session html (str): Return html input hidden with csrf token saved in session
""" """
#s=get_session() #s=get_session()
@ -202,7 +203,7 @@ def generate_csrf():
"""Function for generate a csrf token in a variable """Function for generate a csrf token in a variable
Returns: Returns:
csrf token value csrf_token (str): csrf token value
""" """
if not 'csrf_token' in session: if not 'csrf_token' in session:

View file

@ -21,7 +21,7 @@ class GenerateAdminClass:
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
Attributes: Attributes:
model (WebModel) The webmodel used for generate the admin model form model (WebModel): The webmodel used for generate the admin model form
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
list (SimpleList): A SimpleList class used for generate the listing list (SimpleList): A SimpleList class used for generate the listing
arr_fields_edit (list): A list with the fields that the user can edit arr_fields_edit (list): A list with the fields that the user can edit
@ -83,7 +83,8 @@ class GenerateAdminClass:
Depending of op_admin arg, you have the different sections of a simple administrator Depending of op_admin arg, you have the different sections of a simple administrator
Returns:
html (str): The html content of the admin page, can be, items list, forms for create items, etc...
""" """
op_admin=request.args.get('op_admin', '0') op_admin=request.args.get('op_admin', '0')
@ -251,7 +252,7 @@ class GenerateConfigClass:
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
Attributes: Attributes:
model (WebModel) The webmodel used for generatre the admin model form model (WebModel): The webmodel used for generatre the admin model form
t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate t (PTemplate): Template used for the class. Normally template subclassed from admin_t PTemplate
url (str): Base url used by GenerateConfigClass for different sections of update configuration model url (str): Base url used by GenerateConfigClass for different sections of update configuration model
url_redirect (str): The url where user is redirect when an operation is done url_redirect (str): The url where user is redirect when an operation is done

View file

@ -1,13 +1,4 @@
"""
from settings import config
wsgi_gateway='flask'
if hasattr(config, 'wsgi_gateway'):
wsgi_gateway=config.wsgi_gateway
if wsgi_gateway=='flask':
"""
from flask import request from flask import request
def get_query_args(key, default_value=''): def get_query_args(key, default_value=''):

View file

@ -203,7 +203,7 @@ class SimpleList:
"""Method for join options list returns with jln attributte separator """Method for join options list returns with jln attributte separator
Returns: Returns:
str: Return a string with joined options options (str): Return a string with joined options
""" """
#SimpleList.standard_options(arr_row) #SimpleList.standard_options(arr_row)
return self.jln.join(options_func(self.url, arr_row[self.model.name_field_id], arr_row)) return self.jln.join(options_func(self.url, arr_row[self.model.name_field_id], arr_row))
@ -213,7 +213,7 @@ class SimpleList:
"""Static method for get standar options for make things with the items row. """Static method for get standar options for make things with the items row.
Returns: Returns:
list: Return a list of basic options for items row options (list): Return a list of basic options for items row
""" """
options=[] options=[]
options.append('<a href="'+add_get_parameters(url, op_admin=1, id=id)+'">'+I18n.lang('common', 'edit', 'Edit')+'</a>') options.append('<a href="'+add_get_parameters(url, op_admin=1, id=id)+'">'+I18n.lang('common', 'edit', 'Edit')+'</a>')

View file

@ -30,7 +30,7 @@ def env_theme(module, cache_enabled=True, cache_impl='', cache_args={}, module_d
Returns: Returns:
TemplateLookup: Return TemplateLookup object template (TemplateLookup): Return TemplateLookup object
""" """
@ -113,7 +113,7 @@ class PTemplate:
module (str): Optional. Where is saved the js file. module (str): Optional. Where is saved the js file.
Returns: Returns:
None: Dummy return necessary because mako expect return something dummy (str): Dummy return necessary because mako expect return something
""" """
if not js in self.js: if not js in self.js:
self.js[js]='<script language="Javascript" src="{}"></script>'.format(make_media_url('js/'+js, module)) self.js[js]='<script language="Javascript" src="{}"></script>'.format(make_media_url('js/'+js, module))
@ -140,7 +140,7 @@ class PTemplate:
**arguments (mixed): Extra arguments with variables passed to template **arguments (mixed): Extra arguments with variables passed to template
Returns: Returns:
Return a template rendered using mako class from self.env template (str): Return a template rendered using mako class from self.env
""" """
""" """
@ -182,11 +182,11 @@ class PTemplate:
Experimental method for parse a template, similar to load_template but try cache the template loaded Experimental method for parse a template, similar to load_template but try cache the template loaded
Args: Args:
js (str): The name of js file. Normally you save the file in media/js folder in module or theme template_file (str): The name of template file. The template is searched using configuration defined in self.env
module (str): Optional. Where is saved the js file. **arguments (mixed): Extra arguments with variables passed to template
Returns: Returns:
None: Dummy return necessary because mako expect return something dummy (str): Dummy return necessary because mako expect return something
""" """
if not str(self.env.directories)+'/'+template_file in PTemplate.templates_loaded: if not str(self.env.directories)+'/'+template_file in PTemplate.templates_loaded:

View file

@ -6,22 +6,23 @@ login_name='login'
login_url='.login' login_url='.login'
def db(f): def db(f):
"""Wrapper function for add db connection to your flask function
Wrapper function for add db connection to your flask function. Also close the connection if error or function exection is finished.
Args:
*args : The args of function
**kwds : Standard python extra arguments of function
Returns:
wrapper (function): Return the wrapper.
"""
@wraps(f) @wraps(f)
def wrapper(*args, **kwds): def wrapper(*args, **kwds):
"""Wrapper function for add db connection to your flask function
Wrapper function for add db connection to your flask function. Also close the connection if error or function exection is finished.
Args:
*args (mixed): The args of function
**kwds (mixed): Standard python extra arguments of function
Returns:
wrapper (function): Return the wrapper.
"""
g.connection=WebModel.connection() g.connection=WebModel.connection()
try: try:
@ -41,22 +42,24 @@ def db(f):
return wrapper return wrapper
def login_site(f): def login_site(f):
"""Wrapper function for check login in your flask function
Wrapper function for check a login session in your flask function. If
Args:
*args : The args of function
**kwds : Standard python extra arguments of function
Returns:
wrapper (function): Return the wrapper.
"""
@wraps(f) @wraps(f)
def wrapper(*args, **kwds): def wrapper(*args, **kwds):
"""Wrapper function for check login in your flask function
Wrapper function for check a login session in your flask function. If
Args:
*args : The args of function
**kwds : Standard python extra arguments of function
Returns:
wrapper (function): Return the wrapper.
"""
if not login_name in session: if not login_name in session:
return redirect(url_for(login_url)) return redirect(url_for(login_url))

View file

@ -115,12 +115,12 @@ class SendMail:
With this method you can send email to multiple address, html, and add attachments to email With this method you can send email to multiple address, html, and add attachments to email
Args: Args:
from_adress (str): The adress used for send the email from_address (str): The adress used for send the email
to_address (list): A list of emails where the email will be sended. to_address (list): A list of emails where the email will be sended.
subject (str): The subject of the email subject (str): The subject of the email
message (str): The content of the message message (str): The content of the message
content_type (str): The type of mail content, can be plain or html. content_type (str): The type of mail content, can be plain or html.
attatchments (list): A list with a serie of file paths for attach to the email. attachments (list): A list with a serie of file paths for attach to the email.
""" """
if self.smtp==None: if self.smtp==None: