Re: [Mailman-Users] About PostLimit.py again ( was :To restrict sending email messages per day)

Thanks for these pythons routines, Mark. Since I don't know much about the language, I need some clarification on the part of the code between triple quote marks (""") and also between the lines that have ----------- cut -----. Are these constructs some kind of ad hoc python syntax extensions for commenting out or do they need to be made invisible with prepended # characters?
I would especially like to know whether it's possible to substitute worldtime (gmt) in the places where localtime is referenced. This posting throttling functionality is needed to make a mailman list correspond as closely as possible to the functionality once offered by LISTSERV. Is the part of the code between the cut marks only to be used if the globals M, L, and PERIOD are to be set with list attributes via the extend.py file? Could someone comment the code relating to the global PERIOD and localetime. For my purposes PERIOD could be hardcoded to 24 hours and based on gmt. It looks like the code at http://www.msapiro.net/scripts/PostLimit.py can't be inserted as is into
Mailman/Handlers/PostLimit.py Am I right about that?
Thanks in advance for any help,
Ed
On Sun, Jul 21, 2013 at 8:17 PM, Mark Sapiro <mark@msapiro.net> wrote:
Mark Sapiro wrote:
See <http://www.msapiro.net/scripts/PostLimit.py> (mirrored at <http://fog.ccsf.cc.ca.us/~msapiro/scripts/PostLimit.py>)for a script that limits the number of posts from a member to a list either per calendar day or a configurable period of hours.
It could be made lots fancier with the limit and time period being list attributes or mm_cfg variables instead of hard coded and options to hold rather than reject, but it will work.
I have enhanced the script at the above locations to support a per member limit and/or a per list limit. I have also made it take parameters from list attributes if set there and provided a sample extend.py to enable it and set parameters for a list.
Additionally, I have created a FAQ at <http://wiki.list.org/x/V4Hz> with this information.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan

On 08/08/2013 08:54 AM, e.c. wrote:
Thanks for these pythons routines, Mark. Since I don't know much about the language, I need some clarification on the part of the code between triple quote marks (""") and also between the lines that have ----------- cut -----. Are these constructs some kind of ad hoc python syntax extensions for commenting out or do they need to be made invisible with prepended # characters?
The text contained within the """ marks is a Python docstring. Everything from
"""Handler to limit a member's posts to a list to M per calendar day or M per
through
-------------------------- cut ------------ """
is documentation.
The lines between
-------------------------- cut ------------
lines, i.e., beginning with
import copy
and ending with
mlist.post_period = 0
are what you could put in lists/LISTNAME/extend.py after editing the lines
mlist.post_member_limit = 0
mlist.post_list_limit = 0
mlist.post_period = 0
per the comments preceding them.
I would especially like to know whether it's possible to substitute worldtime (gmt) in the places where localtime is referenced.
Yes. Just replace the four occurrences of time.localtime with time.gmtime. Note that this only affects the time zone for determining the current day if the period is the current day rather than a number of hours.
This posting throttling functionality is needed to make a mailman list correspond as closely as possible to the functionality once offered by LISTSERV. Is the part of the code between the cut marks only to be used if the globals M, L, and PERIOD are to be set with list attributes via the extend.py file? Could someone comment the code relating to the global PERIOD and localetime.
The extend.py or something equivalent is required in any case tio i8nsert the PostLi8mit handler into the list's pipeline.
If period is set to a non-zero value, it is irrelevant whether time is local time or UTC (GMT) because an elapsed number of hours is the same regardless of time zone.
For my purposes PERIOD could be hardcoded to 24 hours and based on gmt.
Just copy the code between the
-------------------------- cut ------------
lines to lists/LISTNAME/extend.py and change
mlist.post_period = 0
to
mlist.post_period = 24
in that file. You will also need to set
mlist.post_member_limit = M
in that file where M is the maximum number of user posts per 24 hour period, e.g.
mlist.post_member_limit = 2
will reject the 3rd post from a member within the last 24 hours, and if you want to limit the total number of list posts, also set mlist.post_list_limit to that limit.
It looks like the code at http://www.msapiro.net/scripts/PostLimit.py can't be inserted as is into
Mailman/Handlers/PostLimit.py
Am I right about that?
No, the code at http://www.msapiro.net/scripts/PostLimit.py is intended to be copied as is to Mailman/Handlers/PostLimit.py
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan
participants (2)
-
e.c.
-
Mark Sapiro