Hi George,
yes, this should be possible and not too difficult. However figuring out where to start to integrate your business logic is not easy. I'm already working on an explanation on poolyx views integrate into pyramid views and how to use a combination of both.
The pyramid docs describe how to use traversal and url dispatch in one application:
But I think the traversal/poolyx way is easier to handle than using url dispatch.
Here is one approach how to do it:
To link your shopping cart business logic to callable urls you can use the poolyx root object (
http://www.poolyx.net/doc/html/api/root.html) as context for the view. Root objects provide the 'IRoot' interface, so your code will only be called on the root level.
For example create a shoppingcart python module and use the following in the modules __init__.py:
from poolyx import ViewConf
from poolyx import IWebsiteRoot
def shoppingcart(context, request):
# shopping cart html page rendering and business logic
# e.g. read the users session, render a checkout form
# .....
return """ My shopping cart """
configuration = ViewConf(name="cart", context=IWebsiteRoot, view=shoppingcart)
Include it in poolyx project directory 'website/__init__.py' by calling
website.modules.append("shoppingcart")
This adds the following url and maps it to the shoppingcart function above.
----------------------------------------------------------------------------------------------------------------------------
Alternative: Using pyramid configuration functions directly this would look like:
def shoppingcart(context, request):
# shopping cart html page rendering and business logic
# e.g. read the users session, render a checkout form
# .....
return """ My shopping cart """
config.add_view(name="cart", context=IWebsiteRoot, view=shoppingcart)
Well, it's just a rough explanation and I don't know your concept for a shopping cart. Do you think this approach fits your needs?
I'm currently working on plugin templates and examples for the webpage and documentation and will add the above as another use case. I'm going to release the next version in about 1 or 2 weeks.
Arndt.
I'm wondering for the current design of Poolyx, is it possible to develop a shopping cart addon for it? Think about a inventory entity in traditional db, is there a way to implement business logic in the CMS? My first impression is that Poolyx is focusing on content only, and as for the natural of traversal pattern in pyramid, is it possible to develop shopping cart in a style like traversal+url dispatch? Coz the major and essential part of the poolyx is traversal, now we need add url dispatch pattern for it. I can't figure out a way to do it.