http://hg.code.sf.net:8000/p/roundup/code/atom-log/tip/roundup/support.py Mercurial Repository: p/roundup/code: roundup/support.py history 2026-04-08T21:39:40-04:00 chore: remove __future print_funcion from code. http://hg.code.sf.net:8000/p/roundup/code/#changeset-9c3ec0a5c7fc88acb8a65632ecc13b2d52380314 John Rouillard rouilj@ieee.org 2026-04-08T21:39:40-04:00 2026-04-08T21:39:40-04:00
changeset 9c3ec0a5c7fc
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description chore: remove __future print_funcion from code.

Not needed as of Python 3.
files
refactor: change some classes to use __slots__ http://hg.code.sf.net:8000/p/roundup/code/#changeset-224ccb8b49ca54569350edb5905b19185a97b092 John Rouillard rouilj@ieee.org 2025-11-03T00:13:04-05:00 2025-11-03T00:13:04-05:00
changeset 224ccb8b49ca
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description refactor: change some classes to use __slots__

Speed up access to and reduce size of some low level classes. A few
classes in security.py, rest.py are heavily used. But for all, it
prevents adding random properties to lower level classes that people
shouldn't be mucking with. While doing this I found some test cases
accessing an invalid property name and this change caused the cases to
crash.

admin.py:

Use new method Role.props_dict() and Permission.props_dict() where
original code just referenced __dict__ when printing Role/Permission.

mlink_expr.py:

Add slots to multiple classes.

Classes Binary and Unary set real properties/attributes. Classes that
inherit from them (Equals, Empty, Not, Or, And) define empty slots
tuple to eliminate need for __dict__.

Class Expression also gets a slot.

rate_limit.py:

RateLimit and Gcra classes get slots.

A couple of pep8 fixes: sort imports, remove trailing spaces on a
line, remove unused noqa comment.

rest.py:

Add slots to class SimulateFieldStorageFromJson and FsValue
classes. The memory savings from this could be useful as well as
speedier access to the attributes.

security.py:

Add slots to Permission class. To prevent conflict between slot
limit_perm_to_props_only and the class variable of the same name,
rename the class variable to limit_perm_to_props_only_default.
Also define method props_dict() to allow other code to get a dict to
iterate over when checking permissions.

Add slots to class Role along with props_dict() method.

Add slots to class Security. Also have to add explicit __dict__ slot
to support test override of the hasPermission() method. Add
props_dict() method, currently unused, but added for symmetry.

support.py:

TruthDict and PrioList gets slots.

test/test_cgi.py:

Fix incorrect setting of permission property. Was setting
permissions. So testing may not have been doing what we thought it
was. Multiple places found with this typo.

Remove setting of permissions in some places where it should
have no effect on the test and looks like it was just copypasta.

test/test_xmlrpc.py

Remove setting of permissions in some places where it should
have no effect on the test and looks like it was just copypasta.
files
test: add tests for support.py: PrioList, Progress, TruthDict http://hg.code.sf.net:8000/p/roundup/code/#changeset-8ef97f7cfb6d750204df60f9b7efca635b488fd5 John Rouillard rouilj@ieee.org 2024-03-30T23:25:43-04:00 2024-03-30T23:25:43-04:00
changeset 8ef97f7cfb6d
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description test: add tests for support.py: PrioList, Progress, TruthDict

Also removed an obsolete comment for Progress.
files
issue2551250: Fix sorting of detectors http://hg.code.sf.net:8000/p/roundup/code/#changeset-33eb82ad26ba3f316773003a28fb5e7d67c72eaa Ralf Schlatterbeck rsc@runtux.com 2022-12-21T20:13:39+01:00 2022-12-21T20:13:39+01:00
changeset 33eb82ad26ba
branch
bookmark
tag
user Ralf Schlatterbeck <rsc@runtux.com>
description issue2551250: Fix sorting of detectors

.. even if there are two with the same name and priority (can happen if
they are created in two different files).
files
flake8 cleanup: remove unused re import; whitespace normalization. http://hg.code.sf.net:8000/p/roundup/code/#changeset-01643d37785f9c5981c07c40364bbbd51d464b02 John Rouillard rouilj@ieee.org 2019-12-31T21:59:07-05:00 2019-12-31T21:59:07-05:00
changeset 01643d37785f
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description flake8 cleanup: remove unused re import; whitespace normalization.
files
Python 3 preparation: avoid assigning to instance __getitem__ in TruthDict. http://hg.code.sf.net:8000/p/roundup/code/#changeset-afd9fd3a0edb6174bd6728ec24a7046bb2a6ee42 Joseph Myers jsm@polyomino.org.uk 2018-07-25T12:29:08+00:00 2018-07-25T12:29:08+00:00
changeset afd9fd3a0edb
branch
bookmark
tag
user Joseph Myers <jsm@polyomino.org.uk>
description Python 3 preparation: avoid assigning to instance __getitem__ in TruthDict.

In Python 3, special method names are generally only looked up at the
class level, not on instance objects, and so assigning to them for an
instance object doesn't work as expected.
files
Python 3 preparation: use // and __truediv__ as needed. http://hg.code.sf.net:8000/p/roundup/code/#changeset-2120f77554d5ebacd5bccdd7692716660a4f32a1 Joseph Myers jsm@polyomino.org.uk 2018-07-24T23:16:09+00:00 2018-07-24T23:16:09+00:00
changeset 2120f77554d5
branch
bookmark
tag
user Joseph Myers <jsm@polyomino.org.uk>
description Python 3 preparation: use // and __truediv__ as needed.

Tool-assisted patch. Those divisions that I thought must be integer
floor divisions and rely on Python 2 integer floor division semantics
are changed to use // (if any are actually meant to be floating-point
divisions, that would break things). One __div__ method is changed to
__truediv__ (with __div__ = __truediv__ for Python 2 compatibility).
files
Python 3 preparation: update next() usage for iterators. http://hg.code.sf.net:8000/p/roundup/code/#changeset-831787cf669468fdff1d0d4ff9b5a90cf6285515 Joseph Myers jsm@polyomino.org.uk 2018-07-24T23:12:32+00:00 2018-07-24T23:12:32+00:00
changeset 831787cf6694
branch
bookmark
tag
user Joseph Myers <jsm@polyomino.org.uk>
description Python 3 preparation: update next() usage for iterators.

Tool-assisted patch. Note that various classes in TAL code with
next() methods are not actually Python iterators and so are not
changed in this patch, but roundup/cgi/ZTUtils/Iterator.py includes
the IterIter class which converts between the two styles of iterator.
files
Python 3 preparation: change "x.has_key(y)" to "y in x". http://hg.code.sf.net:8000/p/roundup/code/#changeset-0942fe89e82e3e84d95a3d0ca5d8d15502f57348 Joseph Myers jsm@polyomino.org.uk 2018-07-24T22:08:17+00:00 2018-07-24T22:08:17+00:00
changeset 0942fe89e82e
branch
bookmark
tag
user Joseph Myers <jsm@polyomino.org.uk>
description Python 3 preparation: change "x.has_key(y)" to "y in x".

(Also likewise "not in" where appropriate.) Tool-generated patch.
files
Python 3 preparation: convert print to a function. http://hg.code.sf.net:8000/p/roundup/code/#changeset-64b05e24dbd889f52bf8f773d3456bd0135baa27 Joseph Myers jsm@polyomino.org.uk 2018-07-24T09:54:52+00:00 2018-07-24T09:54:52+00:00
changeset 64b05e24dbd8
branch
bookmark
tag
user Joseph Myers <jsm@polyomino.org.uk>
description Python 3 preparation: convert print to a function.

Tool-assisted patch. It is possible that some "from __future__ import
print_function" are not in fact needed, if a file only uses print()
with a single string as an argument and so would work fine in Python 2
without that import.
files
Remove wrap and associated functions from roundup.support http://hg.code.sf.net:8000/p/roundup/code/#changeset-ac0c117cd24c4423398b7be42d2fb4f3da6e3282 John Kristensen john@jerrykan.com 2015-02-12T00:55:00+11:00 2015-02-12T00:55:00+11:00
changeset ac0c117cd24c
branch
bookmark
tag
user John Kristensen <john@jerrykan.com>
description Remove wrap and associated functions from roundup.support

The wrap function duplicates functionality that is already provided by
the inbuilt textwrap module since python v2.3. The wrap function is only
used in one place so lets just replace it with the equivalent in-built
function.
files
Remove reversed/sorted from roundup.support http://hg.code.sf.net:8000/p/roundup/code/#changeset-0a05c4d9a2218035f9531a9f06091a158ce1f139 John Kristensen john@jerrykan.com 2014-05-09T23:50:52+10:00 2014-05-09T23:50:52+10:00
changeset 0a05c4d9a221
branch
bookmark
tag
user John Kristensen <john@jerrykan.com>
description Remove reversed/sorted from roundup.support

These shims were providing support for python v2.4, but Roundup no
longer supports v2.4 so we can safely remove them.
files
More transitive-property support. http://hg.code.sf.net:8000/p/roundup/code/#changeset-193f316dbbe96be9b8c424366d56d5afb0623f1e Ralf Schlatterbeck schlatterbeck@users.sourceforge.net 2006-08-21T12:19:48+00:00 2006-08-21T12:19:48+00:00
changeset 193f316dbbe9
branch
bookmark
tag
user Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
description More transitive-property support.

- Implemented transitive properties in sort and group specs. Sort/group
specs can now be lists of specs.
- All regression tests except for one metakit backend test related to
metakit having no representation of NULL pass
- Fixed more PEP 8 whitespace peeves (and probably introduced some new
ones :-)
- Moved Proptree from support.py to hyperdb.py due to circular import
- Moved some proptree-specific methods from Class to Proptree
- Added a test for sorting by ids -> should be numeric sort (which now
really works for all backends)
- Added "required" attribute to all property classes in hyperdb (e.g.,
String, Link,...), see Feature Requests [SF#539081]
-> factored common stuff to _Type. Note that I also converted to a
new-style class when I was at it. Bad: The repr changes for new-style
classes which made some SQL backends break (!) because the repr of
Multilink is used in the schema storage. Fixed the repr to be
independent of the class type.
- Added get_required_props to Class. Todo: should also automagically
make the key property required...
- Add a sort_repr method to property classes. This defines the
sort-order. Individual backends may use diffent routines if the
outcome is the same. This one has a special case for id properties to
make the sorting numeric. Using these methods isn't mandatory in
backends as long as the sort-order is correct.
- Multilink sorting takes orderprop into account. It used to sort by
ids. You can restore the old behaviour by specifying id as the
orderprop of the Multilink if you really need that.
- If somebody specified a Link or Multilink as orderprop, we sort by
labelprop of that class -- not transitively by orderprop. I've
resited the tempation to implement recursive orderprop here: There
could even be loops if several classes specify a Link or Multilink as
the orderprop...
- Fixed a bug in Metakit-Backend: When sorting by Links, the backend
would do a natural join to the Link class. It would rename the "id"
attribute before joining but *not* all the other attributes of the
joined class. So in one test-case we had a name-clash with
priority.name and status.name when sorting *and* grouping by these
attributes. Depending on the order of joining this would produce a
name-clash with broken sort-results (and broken display if the
original class has an attribute that clashes). I'm now doing the
sorting of Links in the generic filter method for the metakit backend.
I've left the dead code in the metakit-backend since correctly
implementing this in the backend will probably be more efficient.
- updated doc/design.html with the new docstring of filter.
files
added StringHTMLProperty wrapped() method to wrap long lines in issue display http://hg.code.sf.net:8000/p/roundup/code/#changeset-f35ece8f8ff71f8055d27008ed2d4dc2aaac5324 Richard Jones richard@users.sourceforge.net 2006-07-31T01:30:05+00:00 2006-07-31T01:30:05+00:00
changeset f35ece8f8ff7
branch
bookmark
tag
user Richard Jones <richard@users.sourceforge.net>
description added StringHTMLProperty wrapped() method to wrap long lines in issue display

also fixed a circular import in roundup.support
files
Of course for Links there is the same bug as I fixed before for multilinks. http://hg.code.sf.net:8000/p/roundup/code/#changeset-fa7becc62534704a571ca9335283a5dcb63cb099 Ralf Schlatterbeck schlatterbeck@users.sourceforge.net 2006-07-13T13:30:39+00:00 2006-07-13T13:30:39+00:00
changeset fa7becc62534
branch
bookmark
tag
user Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
description Of course for Links there is the same bug as I fixed before for multilinks.

But it turns out that searching for None is valid for a link. So we
can't use None as a guard in support.Proptree, I introduced the
has_values flag there and use it in the sql search too.
files
Transitive-property support. http://hg.code.sf.net:8000/p/roundup/code/#changeset-53987aa153d2b247b0e7b816aef7b961b86f0c4b Ralf Schlatterbeck schlatterbeck@users.sourceforge.net 2006-07-13T10:14:56+00:00 2006-07-13T10:14:56+00:00
changeset 53987aa153d2
branch
bookmark
tag
user Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
description Transitive-property support.

- Fixed some of the pet-peeves from pep8
- Better parameter names for new _subselect method
- use new-style class for support.Proptree but needed a new-style class
for the property I introduced anyway.
- Fix a bug where searching did the wrong thing (interestingly enough
the same wrong thing for all backends): A search for
{'messages': ['1'], 'messages.author': ['2']}
would ignore the 'messages' part (messages being non-leaf node in
proptree). Fixed and added a regression test for this.
- Added the transitive searching to the SearchAction. New method
get_transitive_prop introduced in hyperdb that does the transitive
version of getprops()[name]. Fixed two tests to use the (faked) method
instead of getprop.

Now searching for transitive props via the web-interface works for me.
Thanks to alexander smishlajev for pointing me at the coding style.
Sorry for stepping on the peeves -- I'm using a different coding style
in most other projects I'm doing ...
files
Implemented what I'll call for now "transitive searching"... http://hg.code.sf.net:8000/p/roundup/code/#changeset-57c66056ffe475aa40a72b0cdf0d601de6472786 Ralf Schlatterbeck schlatterbeck@users.sourceforge.net 2006-07-08T18:28:18+00:00 2006-07-08T18:28:18+00:00
changeset 57c66056ffe4
branch
bookmark
tag
user Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
description Implemented what I'll call for now "transitive searching"...

...using the filter method. The first idea was mentioned on the
roundup-users mailing list:
http://article.gmane.org/gmane.comp.bug-tracking.roundup.user/6909

We can now search for items which link transitively to other classes
using filter. An example is searching for all items where a certain user
has added a message in the last week:
db.issue.filter (None, {'messages.author' : '42', 'messages.date' : '.-1w;'})
or more readable (but not exactly semantically equivalent, if you're
searching for multiple users in this way it will fail, because string
searches are ANDed): {'messages.author.username':'ralf', ...
We can even extend this further, look for all items that were changed by
users belonging to a certain department (having the same supervisor -- a
property that is not in the user class in standard roundup) in the last
week, the filterspec would be:
{'messages.author.supervisor' : '42', 'messages.date' : '.-1w;'}

If anybody wants to suggest another name instead of transitive
searching, you're welcome.

I've implemented a generic method for this in hyperdb.py -- the backend
now implements _filter in this case. With the generic method, anydbm and
metakit should work (anydbm is tested, metakit breaks for other
reasons). A backend may chose to implement the real transitive filter
itself. This was done for rdbms_common.py. It now has an implementation
of filter that supports transitive searching by creating one big join in
the generated SQL query.

I've added several new regression tests to test for the new features.
All the tests (not just the new ones) run through on python2.3 and
python2.4 with postgres, mysql, sqlite, anydbm -- but metakit was
already broken when I started.

I've generated a tag before commit called 'rsc_before_transitive_search'
and will create the 'after' tag after this commit, so you can merge out
my changes if you don't like them -- if you like them I can remove the
tags.

.-- Ralf
files
woo, that was quick http://hg.code.sf.net:8000/p/roundup/code/#changeset-1be293265e613751201e22f03e10d9a310cd73a1 Richard Jones richard@users.sourceforge.net 2006-03-03T02:51:13+00:00 2006-03-03T02:51:13+00:00
changeset 1be293265e61
branch
bookmark
tag
user Richard Jones <richard@users.sourceforge.net>
description woo, that was quick
files
Features and fixes. http://hg.code.sf.net:8000/p/roundup/code/#changeset-5cd1c83dea5073a312b311fc54fb66374cbda166 Richard Jones richard@users.sourceforge.net 2006-02-06T21:00:47+00:00 2006-02-06T21:00:47+00:00
changeset 5cd1c83dea50
branch
bookmark
tag
user Richard Jones <richard@users.sourceforge.net>
description Features and fixes.

Feature:
- trackers may configure custom stop-words for the full-text indexer

Fixed:
- fixes in scripts/import_sf.py
- fix some unicode bugs in roundup-admin import
- Xapian indexer wasn't actually being used
- fix indexing of message content on roundup-admin import
files
added class PrioList (patch from rfe [SF#413165]) http://hg.code.sf.net:8000/p/roundup/code/#changeset-a2ae111919682a0363916e6eb6f9ce28bdcc40a1 Alexander Smishlajev a1s@users.sourceforge.net 2006-01-24T08:16:59+00:00 2006-01-24T08:16:59+00:00
changeset a2ae11191968
branch
bookmark
tag
user Alexander Smishlajev <a1s@users.sourceforge.net>
description added class PrioList (patch from rfe [SF#413165])
files
First cut at exporting/importing file content from and to the hyperdb. http://hg.code.sf.net:8000/p/roundup/code/#changeset-293a1714976586d586a666ce652873805867d9a5 Johannes Gijsbers jlgijsbers@users.sourceforge.net 2004-12-18T11:12:04+00:00 2004-12-18T11:12:04+00:00
changeset 293a17149765
branch
bookmark
tag
user Johannes Gijsbers <jlgijsbers@users.sourceforge.net>
description First cut at exporting/importing file content from and to the hyperdb.

Unfortunately, I currently set the content using "Class.set", which also
updates the "activity". So testImportExport is broken for tsearch2 right now.

Also did bits of refactoring in hyperdb.FileClass, a tiny step towards making
in-database files backend & indexer-independent.
files
general use http://hg.code.sf.net:8000/p/roundup/code/#changeset-887d631ea2bae919443a08241c040b5095a4e75a Richard Jones richard@users.sourceforge.net 2004-11-30T08:33:11+00:00 2004-11-30T08:33:11+00:00
changeset 887d631ea2ba
branch
bookmark
tag
user Richard Jones <richard@users.sourceforge.net>
description general use
files