misc: replace new module by types module (#36515)

This commit is contained in:
Frédéric Péters 2019-11-11 21:45:25 +01:00
parent 9e2a163383
commit ec790a911d
2 changed files with 12 additions and 6 deletions

View File

@ -14,8 +14,8 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.
import new
import sys
import types
from quixote import get_publisher
from .qommon import _
@ -24,6 +24,9 @@ from wcs.carddata import CardData
from wcs.formdef import FormDef
from wcs.workflows import Workflow
if not hasattr(types, 'ClassType'):
types.ClassType = type
class CardDef(FormDef):
_names = 'carddefs'
@ -45,12 +48,12 @@ class CardDef(FormDef):
if (get_publisher().is_using_postgresql() and not mode == 'files') or mode == 'sql':
from . import sql
table_name = sql.get_formdef_table_name(self)
cls = new.classobj(self.url_name.title(), (sql.SqlCardData,),
cls = types.ClassType(self.url_name.title(), (sql.SqlCardData,),
{'_formdef': self,
'_table_name': table_name})
actions = sql.do_formdef_tables(self)
else:
cls = new.classobj(self.url_name.title(), (CardData,),
cls = types.ClassType(self.url_name.title(), (CardData,),
{'_names': 'card-%s' % self.internal_identifier,
'_formdef': self})
actions = []

View File

@ -17,9 +17,9 @@
import base64
import copy
import glob
import new
import pickle
import sys
import types
import json
import xml.etree.ElementTree as ET
import datetime
@ -44,6 +44,9 @@ from .categories import Category
from . import fields
from . import data_sources
if not hasattr(types, 'ClassType'):
types.ClassType = type
class FormdefImportError(Exception):
def __init__(self, msg, details=None):
@ -263,12 +266,12 @@ class FormDef(StorableObject):
if (get_publisher().is_using_postgresql() and not mode == 'files') or mode == 'sql':
from . import sql
table_name = sql.get_formdef_table_name(self)
cls = new.classobj(self.url_name.title(), (sql.SqlFormData,),
cls = types.ClassType(self.url_name.title(), (sql.SqlFormData,),
{'_formdef': self,
'_table_name': table_name})
actions = sql.do_formdef_tables(self)
else:
cls = new.classobj(self.url_name.title(), (FormData,),
cls = types.ClassType(self.url_name.title(), (FormData,),
{'_names': 'form-%s' % self.internal_identifier,
'_formdef': self})
actions = []