class X_OBJECT:
# -------------
- def deletePyxbObject(self):
- print ('----------- deletePyxbObject', self.nom)
- indice = 0
+ def delObjPyxb(self):
+ print ('----------- delObjPyxb', self.nom)
trouve = False
+ listeArg=[]
for i in self.perePyxb.objPyxb.orderedContent():
- if id(self.objPyxb) == id(i._Content__value) : trouve = True ;break
- indice = indice + 1
+ if id(self.objPyxb) == id(i._Content__value) : trouve = True ;continue
+ listeArg.append(i._Content__value)
if not trouve : print ('objet pas trouve')
- print (self.perePyxb.objPyxb.description)
- del self.perePyxb.objPyxb.__dict__[self.nom]
- print (self.perePyxb.objPyxb.__delattr__)
- #delattr(self.perePyxb.objPyxb,self.nom)
- # PNPN
+ grandPere=self.perePyxb.perePyxb
+ ancienObjPerePyxb=self.perePyxb.objPyxb
+
+ print (listeArg)
+ nvlObjPerePyxb=self.perePyxb.maClasseModeleMetier(*listeArg)
+ print (nvlObjPerePyxb)
+ self.perePyxb.objPyxb=nvlObjPerePyxb
+ self.perePyxb.objPyxb.objAccas=ancienObjPerePyxb.objAccas
+
+ print (self.nom, ' a pour gp ', grandPere)
+ if grandPere : grandPere.reconstruitAvecNvlObj(ancienObjPerePyxb,nvlObjPerePyxb)
+ print ('----------- fin delObjPyxb', self.nom)
- print ('delattr', self.perePyxb.objPyxb,self.nom)
- del self.perePyxb.objPyxb.orderedContent()[indice]
+ def addObjPyxb(self,indiceDansLeContenu):
+ print ('addObjPyxb ds X_OBJECT')
+
+
+ def reconstruitAvecNvlObj(self, ancienObj,nvlObj):
+ print ('reconstruitAvecNvlObj pour', self, self.nom, ancienObj,nvlObj)
+ listeArg=[]
+ for i in self.objPyxb.orderedContent():
+ if id(ancienObj) == id(i._Content__value) : listeArg.append(nvlObj)
+ else : listeArg.append(i._Content__value)
+ nouveauMoiPyxb=self.maClasseModeleMetier(*listeArg)
+ nouveauMoiPyxb.objAccas=self
+ self.objPyxb=nouveauMoiPyxb
+ if self.perePyxb : self.perePyxb.reconstruitAvecNvlObj(self.objPyxb,nouveauMoiPyxb)
+
+
class X_MCSIMP(X_OBJECT):
if not self.cata.modeleMetier : return
#print ('X_MCSIMP buildObjPyxb', self.nom, self,self.valeur)
#if self.nom == 'diameter' :
- # traceback.print_stack()
+ # traceback.print_stack()
# print ('****************************************************')
- # print ('objPyxbDeConstruction', self.objPyxbDeConstruction)
+ #print ('objPyxbDeConstruction', self.objPyxbDeConstruction)
#if self.objPyxbDeConstruction == None : print (self.nom, ' pas de pyxb')
if self.objPyxbDeConstruction != None :
self.objPyxb = self.objPyxbDeConstruction
+ self.objPyxb.objAccas=self
self.maClasseModeleMetier =type(self.objPyxb)
#print (self.maClasseModeleMetier)
self.objPyxbDeConstruction = None
if self.valeur != None : self.objPyxb=self.maClasseModeleMetier(self.valeur)
elif self.definition.into != None and 'TXM' in self.definition.type : self.objPyxb = None
else : self.objPyxb=self.maClasseModeleMetier();
- #self.filsPyxb=None
- #print ('X_MCSIMP', self.nom, self.objPyxb)
+ if self.objPyxb : self.objPyxb.objAccas=self
+ #print ('X_MCSIMP', self.nom, self.objPyxb, )
#print ('fin X_MCSIMP', self.objPyxb, self.nom,self)
def setValeurObjPyxb(self,newVal):
- print ('dans setValeurObjPyxb MCSIMP')
if not self.cata.modeleMetier : return
- # print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb)
+ #print ('dans setValeurObjPyxb MCSIMP ', self.nom)
+ #print (self.nom , ' a pour pere', self.perePyxb, self.perePyxb.nom, self.perePyxb.objPyxb)
if newVal != None : nvlObj=self.maClasseModeleMetier(newVal)
else : nvlObj=self.maClasseModeleMetier()
self.val=newVal
+
setattr(self.perePyxb.objPyxb,self.nom,nvlObj)
- print ('setattr', self.perePyxb.objPyxb,self.nom)
trouve=False
indice=0
for i in self.perePyxb.objPyxb.orderedContent():
indice+=1
if not trouve : print ('Attention souci au changement de valeur de ', self.nom)
self.objPyxb=nvlObj
- print ('iiiiiiiiiiiiiiiiiiiiiiiiiiiiii', nvlObj, id(nvlObj))
- #for i in self.perePyxb.objPyxb.orderedContent():
- # print ('ds le for pour i')
- # print (i._Content__value)
- # print (id(i._Content__value))
- # print (type((i._Content__value)))
- # if id(i._Content__value) == id(self.objPyxb) : break
- # indexOC +=1
-
- #maValeur = getattr(self.perePyxb.objPyxb, self.nom)
- #print ('je change', indexOC)
- #if isinstance(maValeur, pyxb.binding.basis.simpleTypeDefinition):
- #if 1 :
- # print ('jkjkljkljklj')
- # setattr(self.perePyxb.objPyxb,self.nom,nvlObj)
- # self.perePyxb.objPyxb.orderedContent()[indexOC]=self.perePyxb.objPyxb.orderedContent()[-1]
- # del(self.perePyxb.objPyxb.orderedContent()[-1])
- #print ('apres',self.nom, self.perePyxb.objPyxb.orderedContent())
- #else :
- # index=0
- # trouve=False
- # try :
- # for i in maValeur:
- # if id(i) == id(self.objPyxb) :trouve = True ; break
- # index=index+1
- # maValeur[index]=nvlObj
- # self.perePyxb.objPyxb.orderedContent()[indexOC]._Content__value=nvlObj
- # except : pass
- # if not trouve : print (self.nom , 'pas trouve')
-
- #print ('arret programme'); exit()
-
- #print ('id objPyxb',id(self.objPyxb))
- #print ('id objPyxb[0]',id(self.objPyxb[0]))
- #print ('id elt ', id(self.objPyxb._element), self.objPyxb._element, type(self.objPyxb._element), type(self.objPyxb._element()))
- #print (' perePyxb _ElementMap')
- #print (self.perePyxb.objPyxb._ElementMap)
- #index=0
- #for i in self.perePyxb.objPyxb._ElementMap.keys() :
- # print (id(i), ' ', id(self.perePyxb.objPyxb._ElementMap[i]))
- #print (dir(self.perePyxb.objPyxb._ElementMap[i]))
- # print (id(self.perePyxb.objPyxb._ElementMap[i]))
-# index=index+1
- #print (' objPyxb monBinding id')
- #monBinding = getattr(self.perePyxb.objPyxb, self.nom)
- #for i in monBinding : print id(i)
- #print (' perePyxb orderedContent')
- #for i in self.perePyxb.objPyxb.orderedContent():
- # print id(i._Content__value)
- # print (i._Content__value, type(i._Content__value))
- #print (' perePyxb orderedContent')
- #for i in self.perePyxb.objPyxb.content(): print id(i)
-
- #print (self.perePyxb.objPyxb.orderedContent())
- #print (monBinding)
+ self.objPyxb.objAccas=self
+
- def addPyxbObject(self, indiceDsLeContenu):
+ def addObjPyxb(self, indiceDsLeContenu):
if not self.cata.modeleMetier : return
+ print ('addObjPyxb : ajout de ', self.nom, 'en ', indiceDsLeContenu)
# adherence Accas sur le parent
parent=self.parent
while (parent.isBLOC() ): parent=parent.parent
self.perePyxb=parent
+ print ('dans le perePyxb', self.perePyxb.nom)
+ print (dir(self.perePyxb))
self.monNomClasseModeleMetier='T_'+self.nom
self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier)
nvlObj=self.maClasseModeleMetier()
- print ('setattr', self.perePyxb.objPyxb,self.nom)
setattr(self.perePyxb.objPyxb,self.nom,nvlObj)
tampon=self.perePyxb.objPyxb.orderedContent()[-1]
self.objPyxb = nvlObj
+ self.objPyxb.objAccas=self
indexOC=-1
longueur=len(self.perePyxb.objPyxb.orderedContent())
for i in reversed(range(longueur)):
self.perePyxb.objPyxb.orderedContent()[indiceDsLeContenu]=tampon
- #for i in self.perePyxb.objPyxb.orderedContent() :
- # print (i._Content__value, type(i._Content__value))
- #print ('----------------')
-
- #print self.perePyxb.objPyxb.orderedContent()
- #for i in self.perePyxb.objPyxb.orderedContent():
- # print ('valeur de ', i)
- # print (i._Content__value)
- # print (type(i._Content__value))
- # if isinstance(i._Content__value, self.maClasseModeleMetier) :
- # print dir(i._Content__value)
- # self.objPyxb = i._Content__value
- # setattr(self.perePyxb.objPyxb, self.nom, nvlObj)
- # self.perePyxb.objPyxb.orderedContent()[indexOC]=self.perePyxb.objPyxb.orderedContent()[-1]
- # del(self.perePyxb.objPyxb.orderedContent()[-1])
- # indexOC+=1
- #PNPNPNPNPNPNPNPNP
class X_MCCOMPO(X_OBJECT) :
# -------------------------
#
def buildObjPyxb(self,mc_list) :
#print ('________________________________________________')
- #print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list)
+ print ('X_MCCOMPO buildObjPyxb', self.nom, self, mc_list)
if not self.cata.modeleMetier : return
self.listArg=[]
else :
self.listArg.append(objAccas.objPyxb)
objAccas.perePyxb=self
- print (objAccas.nom ,' a pour pere Pyxb', self, self.nom)
+ #print (objAccas.nom ,' a pour pere Pyxb', self, self.nom)
self.monNomClasseModeleMetier='T_'+self.nom
self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier)
#print ('je passe dans le if pour ', self.nom, self.objPyxb, self)
else :
self.objPyxb=self.maClasseModeleMetier(*self.listArg)
- #print ('Fin __________ ', self.nom, self.objPyxb)
+ self.objPyxb.objAccas=self
#print ('X_MCCOMPO', self.nom, self.objPyxb)
#print ('_______________________________________')
- def deletePyxbObject(self):
+ def delObjPyxb(self):
print ('******************************************')
- print ('je passe ds deletePyxbObject pour ', self, self.nom)
+ print ('je passe ds delObjPyxb pour ', self, self.nom)
print (self.perePyxb)
print (dir(self))
print ('******************************************')
for objFils in fils :
fils.perePyxb=self
self.listArg.append(fils.objPyxb)
- #print (fils.nom ,' a pour pere Pyxb', self, self.nom)
+ #print (fils.nom ,' est un MCLIST et a pour pere Pyxb', self, self.nom)
else :
self.listArg.append(fils.objPyxb)
fils.perePyxb=self
- #print (fils.nom ,' a pour pere Pyxb', self, self.nom)
+ #print (fils.nom ,' est un SIMP a pour pere Pyxb', self, self.nom)
# mise a none ? le bloc n a pas d existence en pyxb
self.perePyxb=None
#print ('_______________________________________')
- #print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list)
+ print ('X_MCBLOC buildObjPyxb', self.nom, self, mc_list)
# on rattache ses fils au bloc mais leur pere sera ensuite le MCCOMPO qui contient le bloc
# Pas sur d en avoir besoin du filsPyxb
self.filsPyxb=[]
# --------------------------
def buildObjPyxb(self,mc_list):
- #print ('__________________________________________________________________')
- #print ('X_MCLIST buildObjPyxb traite ds X_MCLIST', self.nom, self)
- #print ('on ne fait rien pour les MCLISTs, cela sera fait dans chaque MCFACT')
- #print ('__________________________________________________________________')
pass
- # detruire la methode suivante
#def build2ObjPyxb(self,mc_list):
# print ('_______________________________________')
# print ('X_MCLIST buildObjPyxb traite ds X_MCLIST', self.nom, self)
def __init__(self):
#print ('_______________________________________')
#print ('X_JDC buildObjPyxb', self)
+ self.perePyxb=None
if not self.cata.modeleMetier : return
self.monNomClasseModeleMetier=self.code
self.maClasseModeleMetier=getattr(self.cata.modeleMetier,self.monNomClasseModeleMetier)
self.objPyxb=self.maClasseModeleMetier()
+ self.objPyxb.objAccas=self
pyxb.GlobalValidationConfig._setContentInfluencesGeneration(pyxb.GlobalValidationConfig.ALWAYS)
pyxb.GlobalValidationConfig._setInvalidElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION)
pyxb.GlobalValidationConfig._setOrphanElementInContent(pyxb.GlobalValidationConfig.RAISE_EXCEPTION)
#print ('fin buildObjPyxb _______________________________________')
- def enregistreEtapePyxb(self,etape):
+ def enregistreEtapePyxb(self,etape,indice=0):
# OK seulement si sequence (choice ? ...)
+ # 01 11 2018
+ # ne fonctionne pas : a reecrire avec les fonctions addObjPyxb et ReconstruitPerePyxb
+ print ( 'hhhhhhhhhhhhhhh enregistreEtapePyxb hhhhhhhhhhhhhhhhhhhhhhhhh')
+ print ('enregistre ds ',self, etape.nom, 'indice = ', indice)
if not self.cata.modeleMetier : return
- print ('enregistreEtapePyxb' , etape)
self.objPyxb.append(etape.objPyxb)
+ print (self.objPyxb.orderedContent())
+ if indice != (len(self.objPyxb.orderedContent()) -1) :
+ tampon=self.objPyxb.orderedContent()[-1]
+ for i in reversed(range(len(self.objPyxb.orderedContent()))):
+ self.objPyxb.orderedContent()[i]=self.objPyxb.orderedContent()[i-1]
+ if i == indice + 1 : break
+ self.objPyxb.orderedContent()[indice]=tampon
+
+ print (self.objPyxb.orderedContent())
etape.perePyxb = self
- #self.toXml()
+ try:
+ self.objPyxb.validateBinding()
+ except pyxb.ValidationError as e:
+ print(e.details())
def toXml(self):
if not self.cata.modeleMetier : return
objAccasEtape=maClasseAccas(**(objEtape.dictArgs))
# attention objAccasEtape = None normal (cf buildSd)
- #print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh')
+ print ( 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh')
#print (objEtape , type(objEtape))
#print (objEtape.dictPyxb)
#print (maClasseAccas)