Ephes Blog

Miscellaneous things. Mostly Weeknotes and links I stumbled upon.


Weeknotes 2024-07-01

, Jochen
ACARS Message From: C-FWJS/WS0456
Message: HI. I JUST ACCIDENTLY CLEARED AN ACARS MESSAGE BEFORE WE COULD READ IT. DO YOU KNOW WHAT IT WAS ABOUT..... --ACARS Drama

I made numerous small fixes and improvements to django-cast. I also dabbled in Rust game development again and can now draw 2D maps in LDtk and load them into a game. It's just a small step forward, but I didn't struggle with the compiler as much as I anticipated - I'm starting to like Rust.

The weather has been lovely lately, so we bought a barbecue and visited a nearby zoo.

Articles

Videos

Weeknotes

TIL

Fediverse

Software

Out of Context Images


Unwrapping functools.wraps: How to Remove Decorators from a Python Function

, Jochen

Sometimes, you need to call a Python function without its decorators. I encountered this need while implementing custom exception handling for the ACS (Assertion Consumer Service) view in django-saml2-auth. This view was decorated with an exception_handler that rendered responses, which interfered with my custom handling. Fortunately, functools.wraps comes to the rescue, storing the original function in a __wrapped__ attribute.

Here’s an example to demonstrate:

from functools import wraps

def heading(f):
    @wraps(f)
    def wrapper(*args, **kwds):
        to_decorate = f()
        return f"<h1>{to_decorate}</h1>"
    return wrapper


@heading
def decorated_hello():
    return "Hello World!"


# Using the decorated function
print(decorated_hello())
# Output: '<h1>Hello World!</h1>'

# Accessing the original, undecorated function
print(decorated_hello.__wrapped__())
# Output: 'Hello World!'

Weeknotes 2024-06-24

, Jochen
I really hate these new "Dyson Airblade" urinals --Souvlaki Space Station

Still battling this stomach bug. Managed to get some work done but didn't have much time for anything else. Filed a PR to fix last week's Wagtail issue and got the alt text for cover images working. Visited old friends near Stuttgart over the weekend for a party.

Articles

Music

Software

Weeknotes

TILs

Fediverse


Python String Capitalization

, Jochen

I frequently copy titles from websites to use as anchor texts for links. However, these titles are often in all caps, and I don’t want to seem like I’m shouting. Previously, I would paste the all-caps title into a Python REPL, convert it to lowercase, and then manually capitalize the necessary words to make it look like a proper title. But today, I discovered a much simpler built-in solution:

>>> print("THIS IS A LOUD TITLE".title())
'This Is A Loud Title'

I had no idea about this function! 😅


Weeknotes 2024-06-17

, Jochen
oh: neurotypicals should really learn to mask better. I know you want to talk about the weather but please just pretend you have a favorite lizard or something, it's not that hard --nota

It was a normal, almost boring work week. For open source, I released a new version of django-cast, now compatible with Wagtail 6.1. The fix turned out to be surprisingly simple: just define window.chooserUrls = {} before using it like this window.chooserUrls.audioChooser = '/cms/audio/audio/chooser/';.Perhaps some Wagtail JavaScript defined window.chooserUrls previously, and version 6.1 no longer does this? Additionally, I added cover images for blogs. For episodes the podcasts iTunes artwork is used as a fallback when a cover image is missing. But what about normal blog posts? And even for podcast episodes, the iTunes artwork might not be appropriate in every situation. Adding a cover image to the blog makes the behavior consistent. I also fixed a bug, where the Podlove player stopped working after HTMX navigation. Finally, I discovered the cause of the mysterious "DataError: PostgreSQL text fields cannot contain NUL (0x00) bytes" errors in the logs. It seems that Wagtail APIViewSets don't validate user input properly.

And then we caught a stomach bug that ruined our weekend.

Articles

Videos

Weeknotes

Fediverse

Software