What should this code do? What is "root"? I get: File "player.py", line 3, in <module> from root import ZodbConnection ImportError: No module named root
On Wed, Mar 17, 2010 at 15:49, rohit <76.ro...@gmail.com> wrote: > I am trying to run a player.py file and have occasionally been getting this > error.Can someone please help me out here. > > > Error::::::::::::::::::::::: > No handlers could be found for logger "ZODB.Connection" > Traceback (most recent call last): > File "C:\Documents and Settings\Arpit\workspace\ > IndianPremierLeagu\src\root\Classes\Player.py", line 114, in <module> > if not root.has_key("Players"): > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\Connection.py", > line 811, in setstate > self._setstate(obj) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\Connection.py", > line 879, in _setstate > self._reader.setGhostState(obj, p) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\serialize.py", > line 595, in setGhostState > state = self.getState(pickle) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\serialize.py", > line 588, in getState > return unpickler.load() > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\serialize.py", > line 479, in _persistent_load > return self.load_oid(reference) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\serialize.py", > line 538, in load_oid > return self._conn.get(oid) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\Connection.py", > line 245, in get > obj = self._reader.getGhost(p) > File > "D:\python\lib\site-packages\zodb3-3.10.0a1-py2.6-win32.egg\ZODB\serialize.py", > line 576, in getGhost > if issubclass(klass, Broken): > TypeError: issubclass() arg 1 must be a class > > > Cheers, > Rohit > > > This is the code of player.py > > from persistent import Persistent > import transaction > from root import ZodbConnection > import Club > > class Player(Persistent): > def > __init__(self,PlayerID,Name,Age,Wage,Batsman,Bowler,Keeper,Height,Weight,Personality,Stamina,Pace,Strength,Fitnessrating,Agility,Reflexes,Jumping,Compusure,Concentration,Influence,HandlingPressure,InnovativeQuotient,Boldness,Adapatability,Determination,Aggression,Loyalty,Flair,HandlingMedia,Decisions,Motivation,FieldPlacement,FrontFoot,BackFoot,StraightDrive,ReverseSweep,Ondrive,BattingTechinique,BowlingSpeed,SlowerDelivery,ReverseSwing,OutSwing,LegBreak,Armball,Flipper,Length,BowlingTechnique,Catching,Thrwoing,BatAwareness,Stumping,BallCollection,FavouredPersonnel,FavouredTeam,Hook,Pull,Defense,CoverDrive,Sweep,LateCut,Cut,Legglance,BowlAwareness,Bouncer,Yorker,Inswing,Offbreak,Doosra,Googly,Line,Chinaman,FieldAwareness,DirectHits,Diving,Glovework,Movement,Communication,Morale,Fitness): > self.PlayerID=PlayerID > self.Name=Name > self.Age=Age > self.Wage=Wage > self.Batsman=Batsman > self.Bowler=Bowler > self.Keeper=Keeper > self.Height=Height > self.Weight=Weight > self.Personality=Personality > self.Stamina=Stamina > self.Pace=Pace > self.Strength=Strength > self.Fitnessrating=Fitnessrating > self.Agility=Agility > self.Reflexes=Reflexes > self.Jumping=Jumping > self.Compusure=Compusure > self.Concentration=Concentration > self.Influence=Influence > self.HandlingPressure=HandlingPressure > self.InnovativeQuotient=InnovativeQuotient > self.Boldness=Boldness > self.Adapatability=Adapatability > self.Determination=Determination > self.Aggression=Aggression > self.Loyalty=Loyalty > self.Flair=Flair > self.HandlingMedia=HandlingMedia > self.Decisions=Decisions > self.Motivation=Motivation > self.FieldPlacement=FieldPlacement > self.FrontFoot=FrontFoot > self.BackFoot=BackFoot > self.StraightDrive=StraightDrive > self.ReverseSweep=ReverseSweep > self.Ondrive=Ondrive > self.BattingTechinique=BattingTechinique > self.BowlingSpeed=BowlingSpeed > self.SlowerDelivery=SlowerDelivery > self.ReverseSwing=ReverseSwing > self.OutSwing=OutSwing > self.LegBreak=LegBreak > self.Armball=Armball > self.Flipper=Flipper > self.Length=Length > self.BowlingTechnique=BowlingTechnique > self.Catching=Catching > self.Thrwoing=Thrwoing > self.BatAwareness=BatAwareness > self.Stumping=Stumping > self.BallCollection=BallCollection > self.FavouredPersonnel=FavouredPersonnel > self.FavouredTeam=FavouredTeam > self.Hook=Hook > self.Pull=Pull > self.Defense=Defense > self.CoverDrive=CoverDrive > self.Sweep=Sweep > self.LateCut=LateCut > self.Cut=Cut > self.Legglance=Legglance > self.BowlAwareness=BowlAwareness > self.Hook=Hook > self.Pull=Pull > self.Defense=Defense > self.CoverDrive=CoverDrive > self.Sweep=Sweep > self.LateCut=LateCut > self.Cut=Cut > self.Legglance=Legglance > self.Bouncer=Bouncer > self.Yorker=Yorker > self.Inswing=Inswing > self.Offbreak=Offbreak > self.Doosra=Doosra > self.Googly=Googly > self.Line=Line > self.Chinaman=Chinaman > self.FieldAwareness=FieldAwareness > self.DirectHits=DirectHits > self.Diving=Diving > self.Glovework=Glovework > self.Movement=Movement > self.Communication=Communication > self.Morale=Morale > self.Fitness=Fitness > > > def clubs(self): > result=[] > for name in self.FavouredTeam: > result.append(Club.findclubsbyname(name)) > return result > > for team in result: > print "Player's favourite teams are %s" % team > > > > > s=ZodbConnection.open_zodb() > root=s[0] > > > > if not root.has_key("Players"): > root['Players'] = {} > PlayerRoot=root["Players"] > > > def listplayers(): > if len(PlayerRoot.values())==0: > print "There are no players." > print > return > for player in PlayerRoot.values(): > print "Name: %s" % player.Name > print > print "Owned by %s" % player.Age > print > print player.FavouredPersonnel > print > > > > > > def > addplayers(PlayerID,Name,Age,Wage,Batsman,Bowler,Keeper,Height,Weight,Personality,Stamina,Pace,Strength,Fitnessrating,Agility,Reflexes,Jumping,Compusure,Concentration,Influence,HandlingPressure,InnovativeQuotient,Boldness,Adapatability,Determination,Aggression,Loyalty,Flair,HandlingMedia,Decisions,Motivation,FieldPlacement,FrontFoot,BackFoot,StraightDrive,ReverseSweep,Ondrive,BattingTechinique,BowlingSpeed,SlowerDelivery,ReverseSwing,OutSwing,LegBreak,Armball,Flipper,Length,BowlingTechnique,Catching,Thrwoing,Awareness,Stumping,BallCollection,FavouredPersonnel,FavouredTeam,Hook,Pull,Defense,CoverDrive,Sweep,LateCut,Cut,Legglance,Bouncer,Yorker,Inswing,Offbreak,Doosra,Googly,Line,Chinaman,DirectHits,Driving,Glovework,Movement,Communication,Morale,Fitness): > if PlayerRoot.has_key(Name): > print "This player is already created" > return > > if Name: > > PlayerRoot[Name]=Player(PlayerID,Name,Age,Wage,Batsman,Bowler,Keeper,Height,Weight,Personality,Stamina,Pace,Strength,Fitnessrating,Agility,Reflexes,Jumping,Compusure,Concentration,Influence,HandlingPressure,InnovativeQuotient,Boldness,Adapatability,Determination,Aggression,Loyalty,Flair,HandlingMedia,Decisions,Motivation,FieldPlacement,FrontFoot,BackFoot,StraightDrive,ReverseSweep,Ondrive,BattingTechinique,BowlingSpeed,SlowerDelivery,ReverseSwing,OutSwing,LegBreak,Armball,Flipper,Length,BowlingTechnique,Catching,Thrwoing,Awareness,Stumping,BallCollection,FavouredPersonnel,FavouredTeam,Hook,Pull,Defense,CoverDrive,Sweep,LateCut,Cut,Legglance,Bouncer,Yorker,Inswing,Offbreak,Doosra,Googly,Line,Chinaman,DirectHits,Driving,Glovework,Movement,Communication,Morale,Fitness) > > root['Players']=PlayerRoot > transaction.commit() > print "Player added" > print > > > > > > > if __name__=="__main__": > while 1: > choice=raw_input("Press 'L' to list players, 'A' to add" > "an player, or 'Q' to quit:") > choice=choice.lower() > if choice=="l": > listplayers() > elif choice=='a': > ID=input("PlayerID:") > name=raw_input("Name:") > age=input("Age:") > wage=input("Wage:") > batsman=input("Batsman:") > bowler=input("Bowler:") > keeper=input("Keeper:") > height=input("Height:") > weight=input("Weight:") > personality=raw_input("Personality:") > stamina=input("Stamina:") > pace=input("Pace:") > strength=input("Strength:") > fitnessrating=input("Fitness:") > agility=input("Agility") > reflexes=input("Reflexes:") > jumping=input("Jumping:") > composure=input("Composure:") > concentration=input("Concentration:") > influence=input("Influence:") > handling_pressure=input("HandlingPressure:") > innovative_quotient=input("InnovativeQuotient:") > boldness=input("Boldness:") > adaptability=input("Adaptability:") > determination=input("Determination:") > aggression=input("Aggression:") > loyalty=input("Loyalty:") > flair=input("Flair:") > handling_media=input("HandlingMedia:") > decisions=input("Decisions:") > motivation=input("Motivation:") > field_placement=input("FieldPlacement:") > frontfoot=input("FrontFoot:") > backfoot=input("Backfoot:") > straight_drive=input("StraightDrive:") > reverse_sweep=input("ReverseSweep:") > ondrive=input("Ondrive:") > batting_technique=input("BattingTechnique:") > bowling_speed=input("BowlingSpeed:") > slower_delivery=input("Slowerdelivery:") > reverse_swing=input("ReverseSwing:") > outswing=input("Outswing:") > legBreak=input("LegBreak:") > armball=input("Armball:") > flipper=input("Flipper:") > length=input("Length:") > bowling_technique=input("BowlingTechnique:") > catching=input("Catching:") > throwing=input("Throwing:") > batawareness=input("BatAwareness:") > stumping=input("Stumping:") > ballcollection=input("BallCollection:") > fav_pers=raw_input('Favoured Personnel: ').split(',') > fav_team=raw_input("Favourite Team:").split(',') > > hook=input("Hook:") > pull=input("Pull:") > defense=input("Defense:") > cover_drive=input("CoverDrive:") > sweep=input("Sweep:") > latecut=input("Latecut:") > cut=input("Cut:") > legglance=input("Legglance:") > bowl_awareness=input("BowlingAwareness:") > bouncer=input("Bouncer:") > yorker=input("Yorker") > inswing=input("Inswing:") > offbreak=input("Offbreak:") > doosra=input("Doosra:") > googly=input("Googly:") > line=input("Line:") > chinaman=input("Chinaman:") > field_awareness=input("FielcAwareness:") > directhits=input("DirectHits:") > diving=input("Diving:") > glovework=input("Glovework:") > movement=input("Movement:") > communication=input("Communication:") > morale=raw_input("Morale:") > fitness=raw_input("Fitness:") > > > > addplayers(ID,name,age,wage,batsman,bowler,keeper,height,weight,personality,stamina,pace,strength,fitness,agility,reflexes,jumping,composure,concentration,influence,handling_pressure,innovative_quotient,boldness,adaptability,determination,aggression,loyalty,flair,handling_media,decisions,motivation,field_placement,frontfoot,backfoot,straight_drive,reverse_sweep,ondrive,batting_technique,bowling_speed,slower_delivery,reverse_swing,outswing,legBreak,armball,flipper,length,bowling_technique,catching,throwing,batawareness,stumping,ballcollection,fav_pers,hook,pull,defense,cover_drive,sweep,latecut,cut,legglance,bowl_awareness,bouncer,yorker,inswing,offbreak,doosra,googly,line,chinaman,field_awareness,directhits,diving,glovework,movement,communication,morale,fitness) > > > elif choice=="q": > break > > > > ZodbConnection.close_zodb(s) > > > Its basically a class file.I have tried debugging and have foudn outthat > removing this line of code result s in no error. > > if not root.has_key("Players"): > root['Players'] = {} > PlayerRoot=root["Players"] > > > But i have the same lines of code in another class file in the same > module.So i cant understnd why this error occurs.Any help would be much > appreciated. > > Thanks, > Rohit. > > _______________________________________________ > For more information about ZODB, see the ZODB Wiki: > http://www.zope.org/Wikis/ZODB/ > > ZODB-Dev mailing list - zodb-...@zope.org > https://mail.zope.org/mailman/listinfo/zodb-dev > > _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org https://mail.zope.org/mailman/listinfo/zodb-dev