示例#1
0
    def setUp(self):
        self.import_ = Import()
        self.import_.save()

        cursor = connection.cursor()
        for command in open( 'dcdata/scripts/contribution_name_indexes.sql', 'r'):
            if command.strip() and not command.startswith('--'):
                cursor.execute(command)
示例#2
0
    def __init__(self, source, description, imported_by, **kwargs):

        self.log_func = sys.stderr.write
        log = kwargs.get('log')
        if log:
            self.log_func = log.warn

        # populate a fieldname/field mapping of model fields
        self.fields = {}
        for field in self.model._meta.fields:
            self.fields[field.name] = field

        # create a record template with field names from model
        # remove any fields that are typical ID fields
        self._new_record = dict([(f, None) for f in self.fields.iterkeys()])
        for key in self.ID_FIELDS:
            if key in self._new_record:
                del self._new_record[key]

        # create a new Import instance and save reference
        self.import_session = Import(source=source,
                                     description=description,
                                     imported_by=imported_by)
        self.import_session.save()