diff --git a/paramecio2/libraries/db/coreforms.py b/paramecio2/libraries/db/coreforms.py index 582070d..f8fc19c 100644 --- a/paramecio2/libraries/db/coreforms.py +++ b/paramecio2/libraries/db/coreforms.py @@ -39,6 +39,7 @@ class BaseForm: self.field=None self.required=False self.txt_error='' + self.error=False self.name_field_id=self.name+'_form' self.help='' diff --git a/paramecio2/libraries/db/webmodel.py b/paramecio2/libraries/db/webmodel.py index 85bfc28..da2f030 100644 --- a/paramecio2/libraries/db/webmodel.py +++ b/paramecio2/libraries/db/webmodel.py @@ -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