google-code-export / evennia

Automatically exported from code.google.com/p/evennia
Other
1 stars 0 forks source link

chargen.py code error, called method doesn't appear to exist #415

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
line 157 of chargen.py

old_char = managers.objects.get_objs_with_key_and_typeclass(charname, 
CHARACTER_TYPECLASS)

Also on like 87.

managers does not have that method, but manager does.  Suspect typo.  

Original issue reported on code.google.com by DancesWi...@gmail.com on 29 Jul 2013 at 12:43

GoogleCodeExporter commented 9 years ago
I presume this error is found using an automated static code checker? It cannot 
find the property because it does (correctly) not initialize until at run-time 
(when the database is actually active). Django managers are created at 
run-time, at which point the contents of managers.objects will hold the 
properties of src.objects.manager. This can be a bit mind-boggling and one of 
those capabilities that differentiate a highly dynamic language like Python 
from compiled languages. 

Easiest way to check if something static is actually missing at run-time is to 
simply test it:
>>> ev.managers.objects.get_objs_with_key_and_typeclass
<<< <bound method ObjectManager.get_objs_with_key_and_typeclass of 
<src.objects.manager.ObjectManager object at 0xa5e3aac>>

It's certainly possible that we can have typos all over the place, but I think 
that in this particular case we are ok. 

Original comment by griatch on 30 Jul 2013 at 6:47

GoogleCodeExporter commented 9 years ago
Ahhh, it's from the db, that makes sense, thank you.  I was thinking typo 
because of the manager/managers thing, didn't realize it was reliant on 
something (manager?) loading it into the db and then referencing it from there. 
 I'll have to pour over how the load happens, I wouldn't have thought of 
loading code into a database instead of just calling the code.  I've read a 
bunch about python over the last five days or so, but the non-static stuff is 
rather weird still.  My CS degree work was mostly Java based, so the OOP and 
syntax stuff are pretty close, at least.

Original comment by DancesWi...@gmail.com on 31 Jul 2013 at 2:24