diff --git a/VERSION b/VERSION index c1f5b7e4..de907de5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 2.00.0 (2012-07-17 10:35:39) dev +Version 2.00.0 (2012-07-17 10:59:23) dev diff --git a/gluon/dal.py b/gluon/dal.py index f6bb3f5e..4ef080de 100644 --- a/gluon/dal.py +++ b/gluon/dal.py @@ -7130,10 +7130,8 @@ class Table(dict): table = field for field in table: if not field.name in fieldnames and not field.type=='id': - field = copy.copy(field) - # correct self references - if not table._actual and field.type == 'reference '+table._tablename: - field.type = 'reference '+self._tablename + t2 = not table._actual and self._tablename + field = field.clone(point_self_references_to=t2) newfields.append(field) fieldnames.add(field.name) else: @@ -7210,7 +7208,7 @@ class Table(dict): archive_table = archive_db.define_table( archive_name, Field(current_record,field_type), - self) + *[field.close(unique=False) for field in self]) self._before_update.append( lambda qset,fs,at=archive_table,cn=current_record: archive_record(qset,fs,at,cn)) @@ -8038,6 +8036,14 @@ class Field(Expression): else: self.requires = requires + def clone(self,point_self_references_to=False,**args): + field = copy.copy(self) + if point_self_references_to and \ + field.type == 'reference %s'+field._tablename: + field.type = 'reference %s' % point_self_references_to + field.__dict__.update(args) + return field + def store(self, file, filename=None, path=None): if self.custom_store: return self.custom_store(file,filename,path) diff --git a/gluon/tools.py b/gluon/tools.py index ebb8bcc6..6276db1d 100644 --- a/gluon/tools.py +++ b/gluon/tools.py @@ -3029,9 +3029,10 @@ class Auth(object): if archive_table_name in table._db: archive_table = table._db[archive_table_name] else: - archive_table = table._db.define_table(archive_table_name, - Field(current_record,table), - table) + archive_table = table._db.define_table( + archive_table_name, + Field(current_record,table), + *[field.close(unique=False) for field in table]) new_record = {current_record:form.vars.id} for fieldname in archive_table.fields: if not fieldname in ['id',current_record]: