prefixes lost in _dashboard dbadmin when using gunicorn and sockets

37 views
Skip to first unread message

Davidiam

unread,
Jun 15, 2026, 1:56:28 AMJun 15
to py4web
Good morning,

We are using gunicorn and sockets in an apache reverse proxy secured by webseal.
We have multiple customers and each customer has mutliple instances, so we need to use prefixes in our configuration.

We managed to get everything working, but as always the _dashboard app is where we had the most difficulty as it is an SPA application.

We couldn't get the dbadmin to accept the prefix as defined in the SCRIPT_NAME variable.  

The issue was coming from the _make_action_button in grid.py  which was not applying the prefix.

We finally had to override the method in our wsgi code :

# Grid patch (optional but safe to keep)

_original_make_action_button = Grid._make_action_button

def patched_make_action_button(self, text, url, *args, **kwargs):

    base = request.environ.get("SCRIPT_NAME", "")

    if base and url.startswith("/") and not url.startswith(base + "/"):

        url = base + url

    return _original_make_action_button(self, text, url, *args, **kwargs)


Grid._make_action_button = patched_make_action_button

 

app = wsgi(

    apps_folder=APPS_FOLDER,

    password_file="./password.txt",

    dashboard_mode="full"

)


Ideally, we would like to see the SCRIPT_NAME taken into account in the function itself.  I just wanted to check if there isn't some other way of achieving the same result in py4web before entering a PR for the change below.  

    def _make_action_button(

        self,

        text,

        url,

        icon=None,

        classes=None,

        kind="grid-button",

        **attrs,

    ):

        if kind:

            classes = join_classes(classes, self.get_style(kind))

 

        if not "_role" in attrs:

            attrs["_role"] = "button"

 

        # FIX FOR GRID AND DBADMIN IN DASHBOARD

        # ADD THIS BLOCK

        base = request.environ.get("SCRIPT_NAME", "")

 

        if base and url.startswith("/") and not url.startswith(base + "/"):

            url = base + url

        # END FIX


        link = A(

            I(_class=self.param.icon_style.complete(icon)) if icon else "",

            _class=classes,

            _href=url,

            **attrs,

        )

        if self.param.include_action_button_text:

            link.append(

                SPAN(

                    XML(" "),

                    text,

                    _class=self.get_style(kind + "-text") if kind else None,

                )

            )

 

        return link

Massimo DiPierro

unread,
Jun 21, 2026, 9:32:14 PM (13 days ago) Jun 21
to py4web
This should not be necessary because all the grid urls are built using the URL helper. Is it possible you have an older _dashboard? Try delete and resinstall is "py4web setup apps"

Davidiam

unread,
Jun 23, 2026, 1:05:29 AM (12 days ago) Jun 23
to py4web
Hi Massimo,

I installed the latest version from pypi:
Successfully installed cffi-2.0.0 cryptography-45.0.7 pluralize-20260519.2 py4web-1.20260520.0 pydal-20260520.0 pygments-2.20.0 pyjwt-2.13.0 requests-2.34.2 rocket3-20260526.0 tornado-6.5.7 yatl-20260518.1

I reinstalled the _dashboard application 
I removed my grid.py  _make_action_button "monkey_patch" from my custom wsgi 
I started the _dashboard app and clicked on the _scaffold application
I opened the "databases in _scaffold" collapsible block and clicked on the "New" button and got a 404 error.  
- It had not applied our prefix.

I then reapplied my monkey_patch and the New button worked again.

Let me know if you want me to create a PR for grid.py

Kind Regards,
David

P.S.: Also as a side note,  in light theme mode, the theme toggle disappears, you just see an empty square in the upper right hand corner of the screen.




Reply all
Reply to author
Forward
0 new messages