Fixes in docstrings

This commit is contained in:
Antonio de la Rosa 2022-05-04 00:36:05 +02:00
parent c91de6863a
commit 1281e385a8
2 changed files with 46 additions and 3 deletions

View file

@ -263,8 +263,18 @@ class WebModel:
Webmodel is a class for create objects that represent models. This models are a mirage of SQL tables. You can create fields, add indexes, foreign keys, and more.
Attributes:
arr_sql_index (dict):
arr_sql_index (dict): Internal dict used for generate mysql index in fields
arr_sql_set_index (dict): Internal dict used for generate mysql index in fields
arr_sql_unique (dict): Internal dict used for generate mysql unique values in fields
arr_sql_set_unique (dict): Internal dict used for generate mysql unique values in fields
last_query (str): The last query execute by WebModel
connection_pool (list): A list used in older versions, deprecated
first_primary_key (PrimaryKeyField): Field used for primary field and create models in database.
model (OrderedDict): Dict used for internal things and create tables.
connections (dict): A dict with the configuration of the mysql connection. You can use this element in config.py. You set elements, normally "default" with typical elements how:
host: Database host, user: The username of mysql db, password: The password of user, db: The name of the db, charset: The charset of database, normally utf8, db_type: The db_type, possible values are mysqldb or pymysql, by default, pymysql.
connection_id (str): The id by default of the selected connection from connections.
"""
__slots__=('sqlclass', 'fields', 'forms')
@ -297,12 +307,44 @@ class WebModel:
@staticmethod
def connection():
"""Static method for make a connection using SqlClass
Returns: Return a SqlClass connection for mysql db.
"""
return SqlClass(WebModel.connections['default'])
# Init the class
def __init__(self, sqlclass=None, name_field_id="id"):
"""
Args:
sqlclass (SqlClass): The SqlClass connection used for the mysql db
name_field_id (str): The name of field id of this model/mysql table
Attributes:
name (str): The name of this model correspondient to the sql table name with lower string.
label (str): Descriptive name, first is used self.name how default.
label_general (str): Descriptive general name, first is used self.name how default.
name_field_id (str): The name of field id of this model/mysql table
fields (OrderedDict): A dict with the fields of model/table based in PhangoField objects.
fields_error (OrderedDict): A dict where the errors when check data fields are saved
related (list): A list where related fields are saved.
forms (OrderedDict): A dict where forms related with fields using how base BaseForm class are saved if you use self.create_forms() method.
errors (dict): A dict where generic errors are saved.
num_errors (int): Number of errors generated by the model on query methods.
query_error (str): If error in query, saved here.
values_query (list): Where the values for a sql query for filtering are saved.
conditions (list): A list used for define the sql conditions.
First element is the sql condition, Example: 'WHERE id=%s', and second element is the variable to substitute %s, example [1]. Complete example: ['WHERE id=%s', 1]
order_by (str): Internal variable used for set the sql order str. You don't shoud change this variable if yo don't know what are you doing.
limit (str): Internal variable used for set the sql limit str.
related_models_deleted (list): Internal variable used for delete tables from db.
required_save (str): Internal variable used for required fields defined in self.fields
primary_key (str): Default name of primary key field
yes_reset_conditions (bool):
"""
self.cached=WebModel.global_cached
@ -326,7 +368,7 @@ class WebModel:
# Errors of fields of the table, for safe thread reasons.
self.fields_error=OrderedDict()
#self.fields_error=OrderedDict()
#The tables related with foreignkeyfield to this table