Re: Trying to build a fully synthesized site

"Joseph S. Tate" <[email protected]> Thu, 27 Oct 2016 21:01:34 +0000
Newsgroups gmane.comp.python.cherrypy
Message-ID <CA+WDQbFxtmdNMjDki+dpUW3b9MqYQfOPCzoejBgSvKfc0C-k1A@mail.gmail.com>
Your description of the problem isn't helping me figure out what you want
to do. Can you give some concrete examples?

There are lots of tool examples that show how to render templates, for
example: http://tools.cherrypy.org/wiki/Jinja

It sounds like you probably want to build a custom dispatcher. When a
request comes in, it gets sent to the appropriate dispatcher (which you can
set up in the config file). The default dispatcher maps the URL to a class
tree, for example. CherryPy ships with a few dispatchers. One of them may
work out of the box, or you may want to look at the code for these and how
you can modify them for your own use.
https://cherrypy.readthedocs.io/en/3.3.0/tutorial/dispatching.html

You may also want to look at the "default" method, which allows you to set
up a single root class, and have it handle all requests. The extra path
info is passed as positional parameters. It's described on the dispatching
page above. You can also write a _cp_dispatch method in your mounted class
that will receive the remainder of the path as a single parameter.
http://docs.cherrypy.org/en/latest/advanced.html#the-special-cp-dispatch-method

Joseph

On Wed, Oct 26, 2016 at 5:00 PM <[email protected]> wrote:

> Hi,
> I am completely new to CherryPy and am trying to do something different
> than a typical web site.
> I am using http to expose data that has be learned within a local
> management tool. My config file allows the user to define a page URL and
> what data is returned in a json dictionary. They can also specify a
> template file (jinja2) and I will feed the data through the template to
> return them the rendered result.
>
> So there are no specific pages that exist, so the define a class or
> function for a page as in the examples doesn't seem to make any sense. I
> want to tell cherrypy which pages exist and then route them all through a
> single routine that looks up the page information and returns json or html.
> What is the best way to do this? This is my whole reason for embedding the
> server.
>
> I might think this could be a good addition to the FAQ, I can't be the
> only person who would want to do this.
>
> thanks,
> jerry
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "cherrypy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
> Visit this group at https://groups.google.com/group/cherrypy-users.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To post to this group, send email to cherrypy-users-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.