-
Notifications
You must be signed in to change notification settings - Fork 886
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting map_hyphen=True in routes.py breaks codemirror editor #769
Comments
To add additional info to this issue, I originally tested it on version 2.9.5, but just now tested it on version 2.9.12 and issue still exists. To reproduce it's quite easy. Download 2.9.12. Then, to the root of the web2py directory add routers = dict(
# base router
BASE=dict(
default_application='welcome',
map_hyphen=True,
),
) Now in the admin interface, click on Reload routes. Now, try to opening and editing any file using the built-in web2py code editor (uses codemirror). |
uhm. I'm not convinced this is the right fix.... and in fact I can't reproduce the original issue....... |
@niphlod Hi, I tested it on a fresh copy of 2.9.12. I don't think it has much to do with commit you're referencing. This is a separate issue and goes back to at least 2.9.5. It has nothing to do with allowing map_hyphen to work for application names as the commit suggest. More system details: Are you reloading the routes after creating the routes.py with the above code in the root dir? |
yep, I am. Are you ? your problem is with urls in static/ but the code ALREADY skips static . Can you make a test that doesn't involve an app (i.e. from the shell)? |
@niphlod I now feel 100% sure this is a bug. I'm sorry you can't reproduce it, maybe you're not doing something right or I'm not being clear. I tried to further debug this. I placed a print statement to see what the value of I then re-started the web2py and refreshed the editor page and checked the terminal and it printed the following values as self.controllers: default
default
default
default
mercurial
default
default
debug
static
static
static
static
static
static
static
static
default
static
static
static
static
default
static/_2.9.12 <---- look
static/_2.9.12 <---- look
static/_2.9.12 <---- look
default
default
default
default
default
default
default
default
static/_2.9.12 <---- look
static/_2.9.12 <---- look
default
default
static Note that the output contains a couple Now check the current code: if self.map_hyphen:
self.controller = self.controller.replace('_', '-') # <--- does not care if static or not, conversion for controller will still take effect, and since `static/_2.9.12` is a "controller" it will get replaced by `static/-2.9.12`
if self.controller != 'static' and not self.controller.startswith('static/'): # <--- since static check is here
self.application = self.application.replace('_', '-')
self.function = self.function.replace('_', '-') In my PR I placed it nested in the static/ check and this has fixed the issue for me: if self.map_hyphen:
if self.controller != 'static' and not self.controller.startswith('static/'):
self.application = self.application.replace('_', '-')
self.controller = self.controller.replace('_', '-') # <- will not get touched since it's inside static/ check
self.function = self.function.replace('_', '-') Let me know if you have more questions. Would like to get the fix merged into master |
if indeed this is happening, the bug is static/something being a controller, not the rewrite logic... |
imho the error is the way admin is coded. {{cm=URL('static%s' % (response.static_version and '/_' + response.static_version or ''),'codemirror')}}
<link rel="stylesheet" href="{{=cm}}/lib/codemirror.css"> this doesn't pass through rewrite logic as it should (calling URL('somethingwithaslashinside') is wrong ) and so the controller passed - in some weird occasion - is 'static/_1.2.3' and everything is screwed up. |
moreover, I found out that there is a subtle bug handling response.static_version and response.static_version_urls ........... stay tuned for a PR that:
@mdipierro : please keep this on hold a bit |
this does not seem to fix the issue with admin. If I set
|
did you fetch the latest admin code ? |
I just pulled from master and it seems to be ok so far... |
I just downloaded master.zip from github and admin still wants to read from admin/static/_2.9.12/ (regardless of what static_version_urls is set to in 0.py; here are the results when static_version_urls=False) :
I have a custom routes.py, but that shouldn't be interfering, since it is literally copied from the examples:
|
what's the problem with that ? what resources are not loaded in your case ? |
The problem is that with static_version_urls=False, admin should not be using static version URLs when Apache is configured with AliasMatch to map ([^/]+)/static/(.*) to applications/$1/static/$2 |
ok, the issue you're mentioning comes from 3 set of distinct set of problems:
|
What I'm saying is I don't want static versioning at all, but there is no way to disable it (in admin) correctly, because gluon/globals.py still adds it, even if static_version_urls= False |
response.static_version = None |
The codemirror breaks once I set the
map_hypen
toTrue
.In my
routes.py
I have:When I try to use the web-based web2py editor it fails to load.
Looking at the console I see the following 404's:
The path goes from being an _2.9.5 to -2.9.5 which is expected behavior for the URLS, however because the directory starts with a _ and gets changed to - it causes problem. For example http://localhost:8000/admin/static/**-2.9.5**/js/typeahead.min.js
The text was updated successfully, but these errors were encountered: