Coder Social home page Coder Social logo

regex is not working in top level app about webpy HOT 3 CLOSED

webpy avatar webpy commented on September 26, 2024
regex is not working in top level app

from webpy.

Comments (3)

 avatar commented on September 26, 2024

I stumbled onto this as well. It appears that while local classes can use regex for URL handling, subapplication URL handling works only with literal strings. Looking in web/application.py around line 421 in the _match() function, the match test uses a startswith() rather than a regex function. This torpedos the design I've been working on, because I assumed (ass == me) that webpy would treat them consistently. So instead of doing URI rest calls that make sense to me:

  • /container/{item-hash}
  • /container/{item-hash}/summary
  • /container/{item-hash}/detail

I have to put static discriminators first so they can get passed off to subapplication classes:

  • /container/{item-hash}
  • /container/summary/{item-hash}
  • /container/detail/{item-hash}

I'm not sure what the purpose was in the inconsistency. When this was implemented, did something prevent treating local classes and subapplications differently? I don't see any comments that might shed light on the code.

from webpy.

iredmail avatar iredmail commented on September 26, 2024

Currently it only supports a hard-coded sub-app URL. For example, in your code.py:

urls = (
    "/(blog|Blog)", blog.app_blog,
    ...
)

it should be changed to something like this:

urls = (
    "/blog", blog.app_blog,
    "/Blog", blog.app_blog,
    ...
)

We have no plan to support regex for sub-application recently, sorry.

from webpy.

iredmail avatar iredmail commented on September 26, 2024

UPDATE: i updated the cookbook to mention this.
http://webpy.org/cookbook/subapp

from webpy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.