Document realm filter regexp oddities

(imported from commit 987d8ea679f40c31f2fe2280b6d585f82b20e606)
This commit is contained in:
Leo Franchi
2014-01-27 13:43:55 -05:00
parent dc3c6f34fc
commit 0917a27b79
2 changed files with 10 additions and 0 deletions

View File

@@ -2284,6 +2284,10 @@ def notify_realm_filters(realm):
notice = dict(event=dict(type="realm_filters", realm_filters=realm_filters), users=user_ids)
tornado_callbacks.send_notification(notice)
# NOTE: Regexes must be simple enough that they can be easily translated to JavaScript
# RegExp syntax. In addition to JS-compatible syntax, the following features are available:
# * Named groups will be converted to numbered groups automatically
# * Inline-regex flags will be stripped, and where possible translated to RegExp-wide flags
def do_add_realm_filter(realm, pattern, url_format_string):
RealmFilter(realm=realm, pattern=pattern,
url_format_string=url_format_string).save()

View File

@@ -11,6 +11,12 @@ class Command(BaseCommand):
Usage: python manage.py realm_filters foo.com PATTERN URLPATTERN
NOTE: Regexes must be simple enough that they can be easily translated to JavaScript
RegExp syntax. In addition to JS-compatible syntax, the following features are available:
* Named groups will be converted to numbered groups automatically
* Inline-regex flags will be stripped, and where possible translated to RegExp-wide flags
Example: python manage.py realm_filters --realm=zulip.com --op=add '#(?P<id>[0-9]{2,8})' 'https://trac.humbughq.com/ticket/%(id)s'
Example: python manage.py realm_filters --realm=zulip.com --op=remove '#(?P<id>[0-9]{2,8})'
Example: python manage.py realm_filters --realm=zulip.com --op=show