Comments, aliases, relations, and translations#

Everything attached to an item that is not one of its fields: comments, old URLs, relations to other items, and translations. The comments examples install plone.app.discussion, and the translations examples install plone.app.multilingual, which is what your site needs too.

Each example uses the client from How to read these pages.

client.comments#

CommentsManager.

Comments on an item (@comments).

client.comments.create#

Add a comment, or a reply to a comment.

See create().

Calls POST /news/release-6-2/@comments (plone.restapi documentation).

client.comments.create("/news/release-6-2", "Great news!")
POST /Plone/++api++/news/release-6-2/@comments HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "text": "Great news!"
}
curl -i -X POST http://localhost:8080/Plone/++api++/news/release-6-2/@comments -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"text":"Great news!"}'

The site answers 204, and the method returns None.

client.comments.list#

Comments of an item.

See list().

Calls GET /news/release-6-2/@comments (plone.restapi documentation).

list(client.comments.list("/news/release-6-2"))
GET /Plone/++api++/news/release-6-2/@comments HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET http://localhost:8080/Plone/++api++/news/release-6-2/@comments -H 'accept: application/json' -u admin:admin
[
  {
    "author_username": "admin",
    "text": {
      "data": "Great news!",
      "mime-type": "text/plain"
    }
  }
]

This shows only author_username, text of each entry.

client.comments.update#

Change the text of a comment.

See update().

Calls GET /news/release-6-2/@comments, PATCH /news/release-6-2/@comments/1793728542687396 (plone.restapi documentation).

comment_id = next(client.comments.list("/news/release-6-2"))["comment_id"]
client.comments.update("/news/release-6-2", comment_id, "Great news, everyone!")
GET /Plone/++api++/news/release-6-2/@comments HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
PATCH /Plone/++api++/news/release-6-2/@comments/1793728542687396 HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "text": "Great news, everyone!"
}
curl -i -X GET http://localhost:8080/Plone/++api++/news/release-6-2/@comments -H 'accept: application/json' -u admin:admin
curl -i -X PATCH http://localhost:8080/Plone/++api++/news/release-6-2/@comments/1793728542687396 -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"text":"Great news, everyone!"}'

The site answers 204, and the method returns None.

client.comments.delete#

Delete a comment.

See delete().

Calls GET /news/release-6-2/@comments, DELETE /news/release-6-2/@comments/1793728542687396 (plone.restapi documentation).

comment_id = next(client.comments.list("/news/release-6-2"))["comment_id"]
client.comments.delete("/news/release-6-2", comment_id)
GET /Plone/++api++/news/release-6-2/@comments HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
DELETE /Plone/++api++/news/release-6-2/@comments/1793728542687396 HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET http://localhost:8080/Plone/++api++/news/release-6-2/@comments -H 'accept: application/json' -u admin:admin
curl -i -X DELETE http://localhost:8080/Plone/++api++/news/release-6-2/@comments/1793728542687396 -H 'accept: application/json' -u admin:admin

The site answers 204, and the method returns None.

client.aliases#

AliasesManager.

URL aliases and redirections (@aliases).

client.aliases.create#

Add aliases to an item.

See create().

Calls POST /news/release-6-2/@aliases (plone.restapi documentation).

client.aliases.create("/news/release-6-2", "/news/plone-6-2")
plone-client aliases add /news/release-6-2 /news/plone-62 -f items_total
{
  "items_total": 2
}
POST /Plone/++api++/news/release-6-2/@aliases HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "items": [
    {
      "path": "/news/plone-6-2"
    }
  ]
}
curl -i -X POST http://localhost:8080/Plone/++api++/news/release-6-2/@aliases -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"items":[{"path":"/news/plone-6-2"}]}'

The site answers 204, and the method returns None.

client.aliases.list#

Aliases of an item, or every redirection of the site.

See list().

Calls GET /news/release-6-2/@aliases (plone.restapi documentation).

client.aliases.list("/news/release-6-2")
plone-client aliases list /news/release-6-2 -f items_total
{
  "items_total": 2
}
GET /Plone/++api++/news/release-6-2/@aliases HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET http://localhost:8080/Plone/++api++/news/release-6-2/@aliases -H 'accept: application/json' -u admin:admin
{
  "items": [
    {
      "path": "/news/plone-6-2"
    },
    {
      "path": "/news/plone-62"
    }
  ],
  "items_total": 2
}

This shows only items, items_total. This shows only path of each entry.

client.aliases.delete#

Remove aliases.

See delete().

Calls DELETE /news/release-6-2/@aliases (plone.restapi documentation).

client.aliases.delete("/news/release-6-2", "/news/plone-6-2")
plone-client aliases remove /news/release-6-2 /news/plone-62
{
  "@id": "http://localhost:8080/Plone/news/release-6-2/@aliases",
  "items": [],
  "items_total": 0
}
DELETE /Plone/++api++/news/release-6-2/@aliases HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "items": [
    {
      "path": "/news/plone-6-2"
    }
  ]
}
curl -i -X DELETE http://localhost:8080/Plone/++api++/news/release-6-2/@aliases -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"items":[{"path":"/news/plone-6-2"}]}'

The site answers 204, and the method returns None.

client.aliases.create_redirects#

Add redirections on the site root.

See create_redirects().

Calls POST /@aliases (plone.restapi documentation).

client.aliases.create_redirects(
    [{"path": "/old-news", "redirect-to": "/news"}]
)
POST /Plone/++api++/@aliases HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "items": [
    {
      "path": "/old-news",
      "redirect-to": "/news"
    }
  ]
}
curl -i -X POST http://localhost:8080/Plone/++api++/@aliases -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"items":[{"path":"/old-news","redirect-to":"/news"}]}'

The site answers 204, and the method returns None.

client.relations#

RelationsManager.

Relations between items (@relations).

client.relations.create#

Create relations.

See create().

Calls POST /@relations (plone.restapi documentation).

client.relations.create(
    [
        {
            "source": "/news/release-6-2",
            "target": "/about",
            "relation": "relatedItems",
        }
    ]
)
POST /Plone/++api++/@relations HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "items": [
    {
      "source": "/news/release-6-2",
      "target": "/about",
      "relation": "relatedItems"
    }
  ]
}
curl -i -X POST http://localhost:8080/Plone/++api++/@relations -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"items":[{"source":"/news/release-6-2","target":"/about","relation":"relatedItems"}]}'

The site answers 204, and the method returns None.

client.relations.stats#

Number of relations of each kind.

See stats().

Calls GET /@relations (plone.restapi documentation).

client.relations.stats()
GET /Plone/++api++/@relations HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET http://localhost:8080/Plone/++api++/@relations -H 'accept: application/json' -u admin:admin
{
  "broken": {},
  "stats": {
    "relatedItems": 1
  }
}

This shows only stats, broken.

client.relations.list#

Relations matching a filter.

See list().

Calls GET /@relations (plone.restapi documentation).

client.relations.list(relation="relatedItems")["relations"]["relatedItems"]
GET /Plone/++api++/@relations?relation=relatedItems HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET 'http://localhost:8080/Plone/++api++/@relations?relation=relatedItems' -H 'accept: application/json' -u admin:admin
{
  "items_total": 1
}

This shows only items_total.

client.relations.delete#

Delete relations, listed one by one or by filter.

See delete().

Calls DELETE /@relations (plone.restapi documentation).

client.relations.delete(relation="relatedItems")
DELETE /Plone/++api++/@relations HTTP/1.1
Host: localhost:8080
Accept: application/json
Content-Type: application/json
Authorization: Basic YWRtaW46YWRtaW4=

{
  "relation": "relatedItems"
}
curl -i -X DELETE http://localhost:8080/Plone/++api++/@relations -H 'accept: application/json' -H 'content-type: application/json' -u admin:admin --data-raw '{"relation":"relatedItems"}'

The site answers 204, and the method returns None.

client.relations.rebuild#

Rebuild the relation catalog.

See rebuild().

Calls POST /@relations/rebuild (plone.restapi documentation).

client.relations.rebuild()
POST /Plone/++api++/@relations/rebuild HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X POST http://localhost:8080/Plone/++api++/@relations/rebuild -H 'accept: application/json' -u admin:admin

The site answers 204, and the method returns None.

client.translations#

TranslationsManager.

Translations of an item (@translations).

client.translations.get#

Translations linked to an item.

See get().

Calls GET /en/about-us/@translations (plone.restapi documentation).

client.translations.get("/en/about-us")
GET /Plone/++api++/en/about-us/@translations HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET http://localhost:8080/Plone/++api++/en/about-us/@translations -H 'accept: application/json' -u admin:admin
{
  "@id": "http://localhost:8080/Plone/en/about-us/@translations",
  "items": [
    {
      "@id": "http://localhost:8080/Plone/pt-br/sobre",
      "language": "pt-br"
    }
  ]
}

This shows only @id, items. This shows only @id, language of each entry.

client.translations.locate#

Where a translation into a language should be created.

See locate().

Calls GET /en/about-us/@translation-locator (plone.restapi documentation).

client.translations.locate("/en/about-us", "pt-br")
GET /Plone/++api++/en/about-us/@translation-locator?target_language=pt-br HTTP/1.1
Host: localhost:8080
Accept: application/json
Authorization: Basic YWRtaW46YWRtaW4=
curl -i -X GET 'http://localhost:8080/Plone/++api++/en/about-us/@translation-locator?target_language=pt-br' -H 'accept: application/json' -u admin:admin
{
  "@id": "http://localhost:8080/Plone/pt-br"
}