Conversation
|
apply() was deprecated ages ago. This introduces at least 2 additional levels of function calls per item cast, which isn't something you want when parsing huge items like alliancelist and transactions. I think I'll do it my way ;-) There's nothing wrong with monkeypatching btw. it's just less elegant. |
|
Yeah I didn't want to use About monkeypatching, that's what i tried on my project but it seems not to work in random cases. Maybe you could help? |
|
what do you mean not work in random cases. as long as you patch immediately after the first "import eveapi" statement, it should work fine. |
|
Here is the monkeypatch that seems not to work in some random cases: http://eve-corp-management.org/projects/ecm/repository/entry/ecm/lib/eveapi_patch.py It is initialized/applied like that : http://eve-corp-management.org/projects/ecm/repository/entry/ecm/apps/common/api.py Then we use our method to create a http://eve-corp-management.org/projects/ecm/repository/entry/ecm/apps/corp/tasks/standings.py The problem is that some (random) users face this error: Which means that the default I know this isn't stackoverflow but maybe you can help :P |
|
Hm, Maybe you should log everything going through autocast. Could be that it's not recognizing a date properly. Or is it working fine if you replace the autocast function in eveapi itself? |
|
It works fine most of the time. And the fact that we have an We added some logging and here's what we got: edit: when we directly modify the default |
|
bizarre :) |
|
try raising an exception in the original autocast :) |
|
Forget it, this error is too much random and "bizarre" as you say ^^ I'll wait for the official way of using a custom |
|
Is it better like this? :) |
|
you know you can just self.autocast(bla) right? |
|
Well, normally It means that the default Something like this: def _autocast(self, key, value):
# attempts to cast an XML string to the most probable type.
try:
if value.strip("-").isdigit():
return int(value)
except ValueError:
pass
try:
return float(value)
except ValueError:
pass
if len(value) == 19 and value[10] == ' ':
# it could be a date string
try:
return max(0, int(timegm(strptime(value, "%Y-%m-%d %H:%M:%S"))))
except OverflowError:
pass
except ValueError:
pass
# couldn't cast. return string unchanged.
return value(or I didn't understand a thing about the python object system) |
|
Ok forget what I said I'm not replacing I wasn't aware that it behaved differently in that case. |
|
Yep, any functions defined in a class accessed through an instance of it will be bound (ie. get reference to class instance added as first parameter). |
|
Hello there :) Do you plan to integrate this feature soon(tm) ? We're kind of waiting for it to make a new release :) cheers o/ |
|
ohgod, pressure :P |
|
any update on this... |

Hey ntt :)
Do you remember talking about an "official" way of having a custom
_autocastfunction without monkey patching your module?I've made something in that direction. I'm pretty sure I didn't break anything and that it would be backward compatible. Could you integrate it?
Thanks o/
diab