django-sboard /

Filename Size Date modified Message
sboard
36 B
2.8 KB
277 B

Node models

Node views

Example node view:

# nodes.py

from zope.component import adapts
from zope.component import provideAdapter

class DetailsView(NodeView):
    # Mandatory part, defines which node this view is adapting.
    adapts(INode)

# Below are listed possible ways, how to tell sistem about your view
existence.

# If name is not provided, it means, that this view is default view for
# adapted node. For example if you access node using this URL: /my-node/,
# then most specific view, without name will be used.
provideAdapter(DetailsView)

# If you specify name, then this view will be used for URL's like this:
/my-node/details/. As you can see, details comes right after node ID.
provideAdapter(DetailsView, name="details")

# You can adapt any existing view to any node, by giving secont parameter,
in this case (ICategory,). This parameter does axactly the same ting as
adapts(ICategory).
provideAdapter(DetailsView, (ICategory,), name="details")

Node URLs

Each node has unique key and may have not unique slug. If node does not have specified slug, then node URL will be constructed from unique key:

0002ar

If node has slug, and slug is unique, then URL will be constructed using that slug:

some-slug-string

If node slug is not unique, then URL will be constructed from slug and key:

some-slug-string+0002ar

We know that slug is not unique from node property ambiguous, if this property is set to True it means, that slug of this node is not unique.

Each node can be accessed directly, just providing direct node URL, described above and with specified action and action name (or action argument). Examples:

/some-slug-string/
/some-slug-string/update/
/some-slug-string/create/comment/

Also, in some cases, action can be a slug, in these cases address looks like this:

/some-slug-string/othre-slug-string/
/some-slug-string/othre-slug-string/action/

See node views section for more information, how view can be accessed using dynamic slugs instead actions.

Als, node can be rendered in specified format, form example:

/some-slug-string.json

This URL returns node in JSON format. You can register your custom formats.

You can get node URL using permalink method or nodeurl template tag.

In python files:

node.permalink()
node.permalink('update')
node.permalink('create', 'comment')
node.permalink(ext='json')

In templates:

{% load sboard %}

<a href="{{ node.permalink }}">{{ node.title }}</a>
<a href="{% nodeurl node 'update' %}">Edit</a>
<a href="{% nodeurl node 'create' 'comment' %}">Create comment</a>
<a href="{% nodeexturl node 'json' %}">JSON</a>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.