Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to implement class register?
#1
I write this code:
Creater.py:
from Database.Tables import Career

class Creater:
    REGISTRY = []
    
    @classmethod
    def register(cls):
        def decorator(child_class):
            cls.REGISTRY.append(child_class)
            return child_class
        
        return decorator
    .....
    .....
    def _create_table(self, table):
        return self.connection.execute(code=table.creating())
    
    def create_tables(self):   
        for table in self.REGISTRY:
            self._create_table(table)
Career.py:
from Database import Creater
from Database.Tables import _TextsQuery

@Creater.Creater.register
class CareerTexts(_TextsQuery.AbstractText):
    TABLE_NAME = 'Career'
    
    @classmethod
    def creating(cls) -> str:
        return '\
        CREATE TABLE ' + cls.TABLE_NAME + ' (\
        id         int,\
        country_id smallint,\
        city_id    smallint,\
        from_year  smallint,\
        until_year smallint,\
        position   varchar(50),\
        PRIMARY KEY(id))'
Output:
@Creater.Creater.register AttributeError: module 'Database.Creater' has no attribute 'Creater'
First, the Creator module is loaded, and as far as I understand it, the Creator module doesn’t full downloading and starts loading the Career module. Since the Creator module did not load, we get an error when loading the Career module.

What can i do?
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Why Can't I call base class function for my derived class object? AmirAB 2 65 Feb-13-2019, 03:04 PM
Last Post: snippsat
  Calling a class inside other class dan789 9 255 Jan-06-2019, 02:00 PM
Last Post: dan789
  simple register code aocii 2 143 Dec-22-2018, 11:15 AM
Last Post: aocii
  Class object instance. Link instance attribute to class. Can it be done easier. Windspar 7 247 Dec-03-2018, 11:16 PM
Last Post: Windspar
  Python script runs on startup but does not register keystrokes. mericanpi 3 380 Sep-07-2018, 02:58 PM
Last Post: mericanpi
  Correct way to implement immutable class QueenSveta 3 842 Jun-20-2018, 07:34 PM
Last Post: snippsat
  How to implement APScheduler in Python 3.6? PrateekG 4 562 Jun-05-2018, 10:13 AM
Last Post: PrateekG
  How to check if class instance exists in a list of class instance objects? sonicblind 23 1,891 May-27-2018, 05:44 AM
Last Post: buran
  Empty attribute class dictionary after saving it in a class object dictionary 3dimensions 6 798 May-20-2018, 01:57 PM
Last Post: 3dimensions
  Why does pyinstaller register success with py to exe, but? Pleiades 1 675 May-09-2018, 11:02 AM
Last Post: Pleiades

Forum Jump:


Users browsing this thread: 1 Guest(s)