EzDevInfo.com

Kotti

Kotti is a high-level, Pythonic web application framework based on Pyramid and SQLAlchemy. It includes an extensible Content Management System called the Kotti CMS. Kotti - Kotti kotti is a high-level, pythonic web application framework. it includes an extensible content management system called the kotti cms, offering all the features you would expect from a modern cms:

Python: Left-side bracket assignment

So I found this code inside Kotti:

[child] = filter(lambda ch: ch.name == path[0], self._children)

And I was wondering: What do the left-hand square brackets do? I did some testing in a python shell, but I can't quite figure out the purpose of it. Bonus question: What does the lambda return? I would guess a tuple of (Boolean, self._children), but that's probably wrong...


Source: (StackOverflow)

How to tell if Pyramid/python is loading the right .egg?

This is a weird question but its been driving me bonkers for the last 3 hours. I wanted to play around with a pyramid based cms Kotti and I made a mistake by installing it using easy_install first(sudo easy_install kotti). I'm getting weird behavior and I'm not sure if its the way the program itself or the way I installed it.

I want to change some parts of the code and see how it works but my changes are not taking effect. After I installed it via easy_install I did:

virtualenv mysite --no-site-packages
bin/easy_install pyramid
git clone https://github.com/Pylons/Kotti.git
cd Kotti
sudo ../bin/python setup.py develop
../bin/pserve app.ini --reload

I went to 127.0.0.0:5000 and saw it was working. The first page has text that says "Congratulations! You have successfully installed Kotti." so I went into the kotti directory and did a grep "Congratulations" *.* and found it was coming from populate.py. So I opened the file and changed the line to a different piece of text and saved. Because I have the --reload flag on pserve I noticed it reloaded my code on the terminal and when I went back to the site the data did not change.

I'm so confused because the server reloads when I change the python code, so it sees the change but its not reflected in the browser(just to test if its the browser cache I tried it using different browsers and cleared the cache).

Any ideas?


Source: (StackOverflow)

Advertisements

Can you have multiple generic subviews of a content element in Kotti?

You can add a 'view' for a content type in kotti by doing something along these lines:

from kotti_mysite.views import poll_view

config.add_view(
    poll_view,
    context=Poll,
    name='view',
    permission='view',
    renderer='kotti_mysite:templates/poll.pt',
)

(more details: http://kotti.readthedocs.org/en/latest/first_steps/tut-2.html)

You can also have multiple views, and use the 'set default view', but sometimes it's convenient to have several similar views with very similar urls.

For example, in plone, its trivial to have a url structure like this:

  • /blah/item/ <--- Normal view
  • /blah/item/json <--- Json version of item
  • /blah/item/pdf <--- PDF download of item

You can... sort of, do a similar thing in kotti by screwing with the view you create and rendering different content based on get/post params, but it's messy, and frankly, rather rubbish.

The only solution I've found is to have a custom content type 'JsonView' that has a json renderer, and add it as a child of the parent object, and it's renderer looks for the parent content, and renders that.

However, doing this requires you to manually create a 'JsonView' child for every instance of the type you want, which is also rather cumbersome.

Is there a better way of doing this?

--

Nb. Specifically note that having a custom view /blah/item/json isn't any use at all; any type of item, in any parent folder should be able to render in the way described above; using a single static route isn't the right solution.


Source: (StackOverflow)