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
  How would I implement copy protection? GalaxyCoyote 1 290 Jul-26-2019, 03:41 PM
Last Post: ThomasL
  I need help with Python code to implement this algorithms Saemmanuex 1 146 Jul-07-2019, 02:07 PM
Last Post: DeaD_EyE
  Call a varaible from class in the parent class Clement_2000 1 310 May-09-2019, 11:14 PM
Last Post: michalmonday
  how to implement the .mymethod() notation of Python Pedroski55 4 310 Apr-22-2019, 10:24 PM
Last Post: Gribouillis
  Trying to implement Python into embedded OS thesurya7 2 189 Apr-02-2019, 06:38 PM
Last Post: ebolisa
  Get variable from class inside another class hcne 3 264 Mar-30-2019, 03:02 PM
Last Post: ichabod801
  Why Can't I call base class function for my derived class object? AmirAB 2 285 Feb-13-2019, 03:04 PM
Last Post: snippsat
  Calling a class inside other class dan789 9 515 Jan-06-2019, 02:00 PM
Last Post: dan789
  simple register code aocii 2 334 Dec-22-2018, 11:15 AM
Last Post: aocii
  Class object instance. Link instance attribute to class. Can it be done easier. Windspar 7 530 Dec-03-2018, 11:16 PM
Last Post: Windspar

Forum Jump:


Users browsing this thread: 1 Guest(s)