Roundup Tracker - Issues

Issue 2551434

classification
Cannot register non-function with registerUtil
Type: crash Severity: normal
Components: Web interface Versions:
process
Status: new
:
: : rouilj, schlatterbeck
Priority: :

Created on 2026-10-12 13:29 by schlatterbeck, last changed 2026-10-12 20:19 by rouilj.

Messages
msg8552 Author: [hidden] (schlatterbeck) Date: 2026-10-12 13:29
I've just upgraded to the latest version in mercurial.
For some re-use in the web interface I'm not just registering functions but also other objects.

I'm now getting a traceback

Traceback (most recent call last):
  File "/home/ralf/roundup/ttt_time2/utils/proplist.py", line 84, in <module>
    db      = tracker.open ('admin')
  File "/usr/local/lib/python3.13/dist-packages/roundup/instance.py", line 123, in open
    extension(self)
    ~~~~~~~~~^^^^^^
  File "./extensions/interfaces.py", line 721, in init
    reg ("ymd",                          common.ymd)
    ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/dist-packages/roundup/instance.py", line 358, in registerUtil
    self.templating_utils[name]._registered_at = (
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute '_registered_at' and no __dict__ for setting new attributes

For one of the occasions I'm trying to register a str.

This used to work.

Why are we setting an attribute 'register_location' to an object registered with registerUtil?
Can we really assume this works for anything that is supposed to be registered there?

If registerUtil is only allowed for function objects we should say so in the docs?
msg8554 Author: [hidden] (rouilj) Date: 2026-10-12 20:19
Hi Ralf:

> For some re-use in the web interface I'm not just registering
functions but also other objects.

I didn't even know that was possible. I though utils were only
functions.
I added calling things as a method to reduce the number of arguments I
needed to pass.
Is registering a string or other object as a util documented somewhere?

The registered_at data allows a useful error message (source for the
other definition)
if a util with the same name is registered twice. It took me a while to
figure out why
my new utility was doing something it shouldn't have been doing before I
added collision
detection to the util registry 8-).

Can you show me the code for registering this string and how it's used
in a template?
With this info I can try to see what options we have.

Also this python is valid:

>>> f = {}
>>> f['a'] = lambda: "foo"
>>> f['a']._stuff = "bar"

so wrapping your string in a lambda might work. Let me know if it does.
It's a (not so great) workaround for sure but ....

Maybe changing the registerUtil function to check the util type and if
it's not a callable
add the property to the util object/class without any source info would
work?

We could also roll back the diagnostic info. I would have to see how
collision detection
would work. Currently you can't register two utils under the same name.
However you can
override a util that is defined on the class.

With an example I may have other ideas (maybe even registerUtilObject()
to
join registerUtilMethod()).

Sorry I broke your stuff.

-- rouilj
History
Date User Action Args
2026-10-12 20:19:32rouiljsettype: crash
messages: + msg8554
components: + Web interface
2026-10-12 13:29:40schlatterbeckcreate