Exemplo n.º 1
0
    def processUserInputs(self, commit = True):
        '''process user inputs and save them to db
        commit: if true, commit to database record. 
        '''

        # prepare a record to accept user inputs
        if self.inventory.id == '':
            record = self.createRecord()
        else:
            record = self.getRecord( )

        # transfer user inputs to db record
        for prop in self.parameters:
            setattr(
                record, prop,
                self.inventory.getTraitValue( prop ) )
            continue

        # commit if requested
        if commit:
            director = self.director
            if empty_id(record.id):
                #if record is new, create a new db record
                id = new_id( director )
                record.id = id
                director.clerk.insertRecord( record )
            else:
                #otherwise, update the record
                director.clerk.updateRecord( record )
            pass # endif
        return record
Exemplo n.º 2
0
    def processUserInputs(self, commit=True):
        '''process user inputs and save them to db
        commit: if true, commit to database record. 
        '''

        # prepare a record to accept user inputs
        if self.inventory.id == '':
            record = self.createRecord()
        else:
            record = self.getRecord()

        # transfer user inputs to db record
        for prop in self.parameters:
            setattr(record, prop, self.inventory.getTraitValue(prop))
            continue

        # commit if requested
        if commit:
            director = self.director
            if empty_id(record.id):
                #if record is new, create a new db record
                id = new_id(director)
                record.id = id
                director.clerk.newRecord(record)
            else:
                #otherwise, update the record
                director.clerk.updateRecord(record)
            pass  # endif
        return record
Exemplo n.º 3
0
    def newReference(self, table, localkey, remotekey):
        '''create a new reference record.

        The new record will not be inserted to the db.
        So you have to do that some time in the future.
        '''
        record = table()
        id = new_id(self.director)
        record.id = id
        record.localkey = localkey
        record.remotekey = remotekey
        return record
Exemplo n.º 4
0
    def newReference(self, table, localkey, remotekey):
        '''create a new reference record.

        The new record will not be inserted to the db.
        So you have to do that some time in the future.
        '''
        record = table()
        id = new_id( self.director )
        record.id = id
        record.localkey = localkey
        record.remotekey = remotekey
        return record
Exemplo n.º 5
0
def new_shape( director ):
    from vnf.dom.Shape import Shape
    record = Shape()

    id = new_id( director )
    record.id = id

    import time
    record.date = time.ctime()

    director.clerk.newRecord( record )
    
    return record
Exemplo n.º 6
0
def new_scatterer( director ):
    from vnf.dom.Scatterer import Scatterer
    record = Scatterer()

    id = new_id( director )
    record.id = id

    import time
    record.date = time.ctime()

    director.clerk.newRecord( record )
    
    return record
Exemplo n.º 7
0
def new_reference(sampleassembly_id, scatterer_id, director):
    from vnf.dom.SampleAssembly import SampleAssembly
    record = SampleAssembly.Scatterers()

    id = new_id(director)
    record.id = id

    record.localkey = sampleassembly_id
    record.remotekey = scatterer_id

    director.clerk.newRecord(record)

    return record
def new_reference( sampleassembly_id, scatterer_id, director ):
    from vnf.dom.SampleAssembly import SampleAssembly
    record = SampleAssembly.Scatterers()

    id = new_id( director )
    record.id = id

    record.localkey = sampleassembly_id
    record.remotekey = scatterer_id

    director.clerk.newRecord( record )
    
    return record
Exemplo n.º 9
0
def new_scatterer(director):
    from vnf.dom.Scatterer import Scatterer
    record = Scatterer()

    id = new_id(director)
    record.id = id

    import time
    record.date = time.ctime()

    director.clerk.newRecord(record)

    return record
Exemplo n.º 10
0
def new_shape(director):
    from vnf.dom.Shape import Shape
    record = Shape()

    id = new_id(director)
    record.id = id

    import time
    record.date = time.ctime()

    director.clerk.newRecord(record)

    return record
Exemplo n.º 11
0
    def new_dbobject(self, table):
        '''create a new record for the given table.

        The given table is assumed to have following fields:
          - id
        '''
        director = self.director

        record = table()

        id = new_id(director)
        record.id = id

        self.newRecord(record)
        return record
Exemplo n.º 12
0
    def new_dbobject(self, table):
        '''create a new record for the given table.

        The given table is assumed to have following fields:
          - id
        '''
        director = self.director
        
        record = table()
        
        id = new_id( director )
        record.id = id

        self.newRecord( record )
        return record
Exemplo n.º 13
0
def new_sampleassembly(director):
    from vnf.dom.SampleAssembly import SampleAssembly
    record = SampleAssembly()

    id = new_id(director)
    record.id = id

    record.constructed = False
    record.short_description = ''
    record.creator = director.sentry.username

    import time
    record.date = time.ctime()

    director.clerk.newRecord(record)

    return record
Exemplo n.º 14
0
def new_sampleassembly( director ):
    from vnf.dom.SampleAssembly import SampleAssembly
    record = SampleAssembly()

    id = new_id( director )
    record.id = id

    record.constructed = False
    record.short_description = ''
    record.creator = director.sentry.username

    import time
    record.date = time.ctime()

    director.clerk.newRecord( record )
    
    return record
Exemplo n.º 15
0
    def new_ownedobject(self, table):
        '''create a new record for the given table.

        The given table is assumed to have following fields:
          - id
          - creator
          - date
        '''
        director = self.director

        record = table()

        id = new_id(director)
        record.id = id

        record.creator = director.sentry.username

        self.newRecord(record)
        return record
Exemplo n.º 16
0
    def new_ownedobject(self, table):
        '''create a new record for the given table.

        The given table is assumed to have following fields:
          - id
          - creator
          - date
        '''
        director = self.director
        
        record = table()
        
        id = new_id( director )
        record.id = id

        record.creator = director.sentry.username
        
        self.newRecord( record )
        return record