Esempio n. 1
0
 def register(self):
     """
     Registers the content items into the database. Registration only works for a 
     postgres user account.
     """
     pg_account = "postgres"   
     
     if self._username == pg_account:
         for c in self.contentItems():
             if isinstance(c,Content):
                 cnt = Content()
                 #self.content=Table('content_base',Base.metadata,autoload=True,autoload_with=STDMDb.instance().engine)
                 qo = cnt.queryObject()
                 cn = qo.filter(Content.code == c.code).first()
                 
                 #If content not found then add
                 if cn == None:                            
                     #Check if the 'postgres' role is defined, if not then create one
                     rl = Role()
                     rolequery = rl.queryObject()
                     role = rolequery.filter(Role.name == pg_account).first()
                     
                     if role == None:
                         rl.name = pg_account
                         rl.contents = [c]
                         rl.save()                     
                     else:
                         existingContents = role.contents
                         #Append new content to existing 
                         existingContents.append(c)
                         role.contents = existingContents
                         role.update()     
Esempio n. 2
0
    def register(self):
        """
        Registers the content items into the database. Registration only works for a
        postgres user account.
        """
        pg_account = "docker"

        if self._username == pg_account:
            for c in self.contentItems():
                if isinstance(c,Content):
                    cnt = Content()
                    qo = cnt.queryObject()
                    cn = qo.filter(Content.code == c.code).first()

                    #If content not found then add
                    if cn == None:
                        #Check if the 'postgres' role is defined, if not then create one
                        rl = Role()
                        rolequery = rl.queryObject()
                        role = rolequery.filter(Role.name == pg_account).first()

                        if role == None:
                            rl.name = pg_account
                            rl.contents = [c]
                            rl.save()
                        else:
                            existingContents = role.contents
                            #Append new content to existing
                            existingContents.append(c)
                            role.contents = existingContents
                            role.update()

            #Initialize lookup values
            initLookups()
Esempio n. 3
0
    def register(self):
        """
        Registers the content items into the database. Registration only works for a 
        postgres user account.
        """
        pg_account = "postgres"

        if self._username == pg_account:
            for c in self.contentItems():
                if isinstance(c, Content):
                    cnt = Content()
                    qo = cnt.queryObject()
                    cn = qo.filter(Content.code == c.code).first()

                    #If content not found then add
                    if cn == None:
                        #Check if the 'postgres' role is defined, if not then create one
                        rl = Role()
                        rolequery = rl.queryObject()
                        role = rolequery.filter(
                            Role.name == pg_account).first()

                        if role == None:
                            rl.name = pg_account
                            rl.contents = [c]
                            rl.save()
                        else:
                            existingContents = role.contents
                            #Append new content to existing
                            existingContents.append(c)
                            role.contents = existingContents
                            role.update()

            #Initialize lookup values
            initLookups()