Databaser

Doc


A Databaser rises to the DatabaserClass. This latter is the deepest class for instancing Variables able to store values in hierarchic tables. Here, as a first step, the database method helps to set the in the dict


View the Databaser notebook on [NbViewer](http://nbviewer.ipython.org/url/shareyoursystem.ouvaton.org/Databaser.ipynb)

Code



# -*- coding: utf-8 -*-
"""


<DefineSource>
@Date : Fri Nov 14 13:20:38 2014 \n
@Author : Erwan Ledoux \n\n
</DefineSource>


A Databaser rises to the DatabaserClass. This latter is the deepest class for instancing
Variables able to store values in hierarchic tables. Here, as a first step,
the database method helps to set the <DatabasingKeyStr> in the __dict__

"""

#<DefineAugmentation>
import ShareYourSystem as SYS
BaseModuleStr="ShareYourSystem.Standards.Noders.Structurer"
DecorationModuleStr="ShareYourSystem.Standards.Classors.Classer"
SYS.setSubModule(globals())
#</DefineAugmentation>

#<ImportSpecificModules>
#</ImportSpecificModules>

#<DefineClass>
@DecorationClass(**{'ClassingSwitchMethodStrsList':['database']})
class DatabaserClass(
                        BaseClass
                ):

    #Definition
    RepresentingKeyStrsList=[
                                'ModeledSuffixStr',
                                'DatabasedCollectionStr',
                                'ModeledSuffixStr',
                                'ModeledPointDeriveControllerVariable'
                            ]

    def default_init(self,
                    _DatabasingKeyStr="",
                    _DatabasedCollectionStr="",
                    _ModeledSuffixStr="",
                    _ModeledPointDeriveControllerVariable=None,
                    **_KwargVariablesDict
                ):

        #Call the parent __init__ method
        BaseClass.__init__(self,**_KwargVariablesDict)

    def do_database(self):

        #set
        if hasattr(self,'NodeKeyStr'):
            self.DatabasingKeyStr=self.NodeKeyStr
            self.DatabasedCollectionStr=self.NodeCollectionStr

        #set
        self.ModeledSuffixStr=self.DatabasingKeyStr+'Model'

        #
        if hasattr(self,'NodePointDeriveNoder'):
            self.point(
                self.NodePointDeriveNoder,
                'ModeledPointDeriveControllerVariable'
            )

#</DefineClass>

View the Databaser sources on Github

Example

Let's create an empty class, which will automatically receive special attributes from the decorating ClassorClass, specially the NameStr, that should be the ClassStr without the TypeStr in the end.


In [3]:
#ImportModules
import ShareYourSystem as SYS
from ShareYourSystem.Standards.Controllers import Storer
from ShareYourSystem.Standards.Modelers import Databaser

#Definition of a Storer instance with a noded databaser
MyStorer=Storer.StorerClass().collect(
    "Datome",
    "Things",
    Databaser.DatabaserClass()
)

#database
MyStorer['<Datome>ThingsDatabaser'].database()
    
#Definition the AttestedStr
SYS._attest(
    [
        'MyStorer is '+SYS._str(
        MyStorer,
        **{
            'RepresentingBaseKeyStrsListBool':False,
            'RepresentingAlineaIsBool':False
        }
        )
    ]
)

#Print



*****Start of the Attest *****

MyStorer is < (StorerClass), 4565658960>
   /{ 
   /  '<New><Instance>DatomeCollectionOrderedDict' : 
   /   /{ 
   /   /  'ThingsDatabaser' : < (DatabaserClass), 4565657936>
   /   /   /{ 
   /   /   /  '<New><Instance>IdInt' : 4565657936
   /   /   /  '<New><Instance>NewtorkAttentionStr' : 
   /   /   /  '<New><Instance>NewtorkCatchStr' : 
   /   /   /  '<New><Instance>NewtorkCollectionStr' : 
   /   /   /  '<New><Instance>NodeCollectionStr' : Datome
   /   /   /  '<New><Instance>NodeIndexInt' : 0
   /   /   /  '<New><Instance>NodeKeyStr' : ThingsDatabaser
   /   /   /  '<New><Instance>NodePointDeriveNoder' : {...}< (StorerClass), 4565658960>
   /   /   /  '<New><Instance>NodePointOrderedDict' : {...}< (OrderedDict), 4565725264>
   /   /   /  '<Spe><Instance>DatabasedCollectionStr' : Datome
   /   /   /  '<Spe><Instance>ModeledPointDeriveControllerVariable' : {...}< (StorerClass), 4565658960>
   /   /   /  '<Spe><Instance>ModeledSuffixStr' : ThingsDatabaserModel
   /   /   /}
   /   /}
   /  '<New><Instance>IdInt' : 4565658960
   /  '<New><Instance>NewtorkAttentionStr' : 
   /  '<New><Instance>NewtorkCatchStr' : 
   /  '<New><Instance>NewtorkCollectionStr' : 
   /  '<New><Instance>NodeCollectionStr' : Globals
   /  '<New><Instance>NodeIndexInt' : -1
   /  '<New><Instance>NodeKeyStr' : TopStorer
   /  '<New><Instance>NodePointDeriveNoder' : None
   /  '<New><Instance>NodePointOrderedDict' : None
   /  '<Spe><Class>StoringOrganizeIsBool' : False
   /}

*****End of the Attest *****