lorb <[email protected]> added the comment:
Thanks for the review and response. I don't understand yet why not to
allow the following while keeping the existing functionality. This
could also be achieved by turning the namer and rotator into class
attributes. I recently created a subclass of the timed rotating
handler where it is beneficial for the handler to be able to access to
self to use the rollover time in the naming.
class MyHandler(BaseRotatingHandler):
def namer(self, default_name):
return default_name # or whatever you want here
def rotator(self, source, dest):
os.rename(source, dest) # or whatever you want here
Am Mi., 6. Nov. 2019 um 11:35 Uhr schrieb Vinay Sajip <[email protected]>:
>
>
> Vinay Sajip <[email protected]> added the comment:
>
> The namer and rotator attributes are callables, not methods to be overridden.
> You can certainly do this with methods and set them accordingly:
>
> class MyHandler(BaseRotatingHandler):
> def __init__(self, *args, **kwargs):
> super(MyHandler, self).__init__(*args, **kwargs)
> self.namer = self.my_namer
> self.rotator = self.my_rotator
>
> def my_namer(self, default_name):
> return default_name # or whatever you want here
>
> def my_rotator(self, source, dest):
> os.rename(source, dest) # or whatever you want here
>
> Having namer and rotator be callables avoids the need to subclass a handler
> just to override naming and rotating functionality. So, I think this issue
> should be closed as "not a bug", and the corresponding PR closed. Thanks for
> your effort, though - I just think you may have misunderstood the intent of
> the design.
>
> ----------
> nosy: +vinay.sajip
>
> _______________________________________
> Python tracker <[email protected]>
> <https://bugs.python.org/issue38716>
> _______________________________________
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue38716>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com