-
Notifications
You must be signed in to change notification settings - Fork 19
/
_content.py
719 lines (473 loc) · 18.5 KB
/
_content.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
##############################################################################
#
# Copyright (c) 2005 Zope Foundation and Contributors.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
""" CMFCore content interfaces.
"""
from zope.interface import Interface
#
# Contentish interface
#
class IContentish(Interface):
""" General interface for "contentish" items.
o These methods need to be implemented by any class that wants to be a
first-class citizen in the CMF world.
o CMFCore.PortalContent implements this interface.
"""
__module__ = 'Products.CMFCore.interfaces'
def SearchableText():
""" Return a string containing textual information about the content.
o This string may be the content of a file, or may be synthesized
by concatenating the string attributes of the instance.
o Permissions: View
"""
#
# Discussable interfaces
#
class IDiscussable(Interface):
""" Interface for things which can have responses.
"""
__module__ = 'Products.CMFCore.interfaces'
def createReply(title, text, Creator=None):
""" Create a reply in the proper place.
o Returns: HTML (directly or via redirect) # XXX
o Permission: Reply to item
"""
def getReplies():
""" Return a sequence of IDiscussionResponse objects which are
replies to this IDiscussable
o Permission: View
"""
def quotedContents():
""" Return this object's contents in a form suitable for inclusion
as a quote in a response.
o The default implementation returns an empty string. It might be
overridden to return a '>' quoted version of the item.
o Permission: Reply to item
"""
def _getReplyResults():
""" Return the ZCatalog results that represent this object's replies.
o XXX: Huh?
o Often, the actual objects are not needed. This is less expensive
than fetching the objects.
o Permission: View
"""
class IOldstyleDiscussable(Interface):
""" Oldstyle discussable interface.
"""
__module__ = 'Products.CMFCore.interfaces'
def createReply(title, text, REQUEST, RESPONSE):
""" Create a reply in the proper place.
o Returns: HTML (directly or via redirect) # XXX
o Permission: Reply to item
"""
def getReplyLocationAndID(REQUEST):
"""
This method determines where a user's reply should be stored, and
what it's ID should be.
You don't really want to force users to have to select a
unique ID each time they want to reply to something. The
present implementation selects a folder in the Member's home
folder called 'Correspondence' (creating it if it is missing)
and finds a free ID in that folder.
createReply should use this method to determine what the reply
it creates should be called, and where it should be placed.
This method (and createReply, I expect) do not really belong in
this interface. There should be a DiscussionManager singleton
(probably the portal object itself) which handles this.
Permissions: None assigned
Returns: 2-tuple, containing the container object, and a string ID.
"""
def getReplyResults():
"""
Return the ZCatalog results that represent this object's replies.
Often, the actual objects are not needed. This is less expensive
than fetching the objects.
Permissions: View
Returns: sequence of ZCatalog results representing DiscussionResponses
"""
def getReplies():
"""
Return a sequence of the DiscussionResponse objects which are
associated with this Discussable
Permissions: View
Returns: sequence of DiscussionResponses
"""
def quotedContents():
"""
Return this object's contents in a form suitable for inclusion
as a quote in a response. The default implementation returns
an empty string. It might be overridden to return a '>' quoted
version of the item.
"""
class IDiscussionResponse(Interface):
""" Interface for objects which are replies to IDiscussable objects.
"""
__module__ = 'Products.CMFCore.interfaces'
def inReplyTo(REQUEST=None):
""" Return the IDiscussable object to which this item is a reply.
o Permission: None assigned
"""
def setReplyTo(reply_to):
""" Make this object a response to the passed object.
o 'reply_to' is an IDiscussable, or a path (as a string) to one.
o Raise ValueError if 'reply_to' is not an IDiscussable (or doesn't
resolve to one as a path).
o XXX This does not seem like the right exception.
o Permission: None assigned
"""
def parentsInThread(size=0):
""" Return a sequence of IDiscussables which are this object's parents,
from the point of view of the threaded discussion.
o Parents are ordered oldest to newest.
o If 'size' is not zero, only the closest 'size' parents will be
returned.
"""
#
# DublinCore interfaces
#
class IMinimalDublinCore(Interface):
""" Minimal set of Dublin Core metadata elements.
"""
__module__ = 'Products.CMFCore.interfaces'
def Title():
""" Return a single string, the DCMI Title element (resource name).
o Permission: View
"""
def Description():
""" Return the DCMI Description element (resource summary).
o Result is a natural language description of this object.
o Permission: View
"""
def Type():
""" Return the DCMI Type element (resource type).
o Result a human-readable type name for the resource (typically
the Title of its type info object).
o Permission: View
"""
class IDublinCore(IMinimalDublinCore):
""" Dublin Core metadata elements supported by CMF and their semantics.
"""
__module__ = 'Products.CMFCore.interfaces'
def listCreators():
""" Return a sequence of DCMI Creator elements (resource authors).
o Depending on the implementation, this returns the full name(s) of the
author(s) of the content object or their ids.
o Permission: View
"""
def Creator():
""" Return the first DCMI Creator element, or an empty string.
o Permission: View
"""
def Subject():
""" Return a sequence of DCMI Subject elements (resource keywords).
o Result is zero or more keywords associated with the content object.
o Permission: View
"""
def Publisher():
""" Return the DCMI Publisher element (resource publisher).
o Result is the full formal name of the entity or person responsible
for publishing the resource.
o Permission: View
"""
def listContributors():
""" Return a sequence of DCMI Contributor elements (resource
collaborators).
o Return zero or more collaborators (beyond thos returned by
'listCreators').
o Permission: View
"""
def Contributors():
""" Deprecated alias for 'listContributors'.
o 'initial caps' names are reserved for strings.
"""
def Date(zone=None):
""" Return the DCMI Date element (default resource date).
o Result is a string, formatted 'YYYY-MM-DD H24:MN:SS TZ'.
o If 'zone' is 'None', return the time in the system default
timezone.
o Permission: View
"""
def CreationDate(zone=None):
""" Return the DCMI Date element (date resource created).
o Result is a string, formatted 'YYYY-MM-DD H24:MN:SS TZ'.
o If 'zone' is 'None', return the time in the system default
timezone.
o Permission: View
"""
def EffectiveDate(zone=None):
""" Return the DCMI Date element (date resource becomes effective).
o Result is a string, formatted 'YYYY-MM-DD H24:MN:SS TZ', or
None.
o If 'zone' is 'None', return the time in the system default
timezone.
o Permission: View
"""
def ExpirationDate(zone=None):
""" Return the DCMI Date element (date resource expires).
o Result is a string, formatted 'YYYY-MM-DD H24:MN:SS TZ', or
None.
o If 'zone' is 'None', return the time in the system default
timezone.
o Permission: View
"""
def ModificationDate(zone=None):
""" DCMI Date element - date resource last modified.
o Result is a string, formatted 'YYYY-MM-DD H24:MN:SS TZ'.
o If 'zone' is 'None', return the time in the system default
timezone.
o Permission: View
"""
def Format():
""" Return the DCMI Format element (resource format).
o Result is the resource's MIME type (e.g. 'text/html',
'image/png', etc.).
o Permission: View
"""
def Identifier():
""" Return the DCMI Identifier element (resource ID).
o Result is a unique ID (a URL) for the resource.
o Permission: View
"""
def Language():
""" DCMI Language element (resource language).
o Result it the RFC language code (e.g. 'en-US', 'pt-BR') for the
resource.
o Permission: View
"""
def Rights():
""" Return the DCMI Rights element (resource copyright).
o Return a string describing the intellectual property status, if
any, of the resource.
o Permission: View
"""
class ICatalogableDublinCore(Interface):
""" Provide Zope-internal date attributes for cataloging purposes.
"""
__module__ = 'Products.CMFCore.interfaces'
def created():
""" Return the DateTime form of CreationDate.
o Permission: View
"""
def effective():
""" Return the DateTime form of EffectiveDate.
o Permission: View
"""
def expires():
""" Return the DateTime form of ExpirationDate.
o Permission: View
"""
def modified():
""" Return the DateTime form of ModificationDate
o Permission: View
"""
class IMutableMinimalDublinCore(IMinimalDublinCore):
""" Update interface for minimal set of mutable metadata.
"""
__module__ = 'Products.CMFCore.interfaces'
def setTitle(title):
""" Set DCMI Title element - resource name.
o Permission: Modify portal content
"""
def setDescription(description):
""" Set DCMI Description element - resource summary.
o Permission: Modify portal content
"""
class IMutableDublinCore(IMutableMinimalDublinCore, IDublinCore):
""" Update interface for mutable metadata.
"""
__module__ = 'Products.CMFCore.interfaces'
def setCreators(creators):
""" Set DCMI Creator elements - resource authors.
o Permission: Modify portal content
"""
def setSubject(subject):
""" Set DCMI Subject element - resource keywords.
o Permission: Modify portal content
"""
def setContributors(contributors):
""" Set DCMI Contributor elements - resource collaborators.
o Permission: Modify portal content
"""
def setEffectiveDate(effective_date):
""" Set DCMI Date element - date resource becomes effective.
o Permission: Modify portal content
"""
def setExpirationDate(expiration_date):
""" Set DCMI Date element - date resource expires.
o Permission: Modify portal content
"""
def setFormat(format):
""" Set DCMI Format element - resource format.
o Permission: Modify portal content
"""
def setLanguage(language):
""" Set DCMI Language element - resource language.
o Permission: Modify portal content
"""
def setRights(rights):
""" Set DCMI Rights element - resource copyright.
o Permission: Modify portal content
"""
#
# DynamicType interfaces
#
class IDynamicType(Interface):
""" General interface for dynamic items.
"""
__module__ = 'Products.CMFCore.interfaces'
def getPortalTypeName():
""" Return the name of the type information for this object.
o If the object is uninitialized, return None.
o Permission: Public
"""
def getTypeInfo():
""" Return the ITypeInformation object for this object.
o A shortcut to 'getTypeInfo' of portal_types.
o Permission: Public
"""
def getActionInfo(action_chain, check_visibility=0, check_condition=0):
""" Get an Action info mapping specified by a chain of actions.
o A shortcut to 'getActionInfo' of the related ITypeInformation
object.
o Permission: Public
"""
def getIconURL():
""" Get the absolute URL of the icon for the object.
o This method is used in the 'folder_contents' view to generate an
appropriate icon for the items found in the folder.
o If the content item does not define an attribute named "icon"
return a "default" icon path (e.g., ``/misc_/dtmldoc.gif``, which is
the icon used for DTML Documents).
o Permission: Public
"""
class ICatalogAware(Interface):
""" Interface for notifying the catalog tool.
"""
__module__ = 'Products.CMFCore.interfaces'
def indexObject():
""" Index the object in the portal catalog.
"""
def unindexObject():
""" Unindex the object from the portal catalog.
"""
def reindexObject(idxs=[]):
""" Reindex the object in the portal catalog.
If idxs is present, only those indexes are reindexed. The metadata is
always updated.
Also update the modification date of the object, unless specific
indexes were requested.
"""
def reindexObjectSecurity(skip_self=False):
""" Reindex security-related indexes on the object.
Recurses in the children to reindex them too.
If skip_self is True, only the children will be reindexed. This is a
useful optimization if the object itself has just been fully
reindexed, as there's no need to reindex its security twice.
"""
class IWorkflowAware(Interface):
""" Interface for notifying the workflow tool.
"""
__module__ = 'Products.CMFCore.interfaces'
def notifyWorkflowCreated():
""" Notify the workflow that the object was just created.
"""
class IOpaqueItemManager(Interface):
"""Interface for managing opaque items.
"""
__module__ = 'Products.CMFCore.interfaces'
#
# Folderish interfaces
#
class IFolderish(Interface):
""" General interface for "folderish" content items.
"""
__module__ = 'Products.CMFCore.interfaces'
def contentItems(filter=None):
""" Return a sequence of (object ID, object) tuples for
IContentish and IFolderish sub-objects.
o Provide a filtered view onto 'objectItems', allowing only
"content space" objects to show through.
o Permission: Public (not publishable)
"""
def contentIds(filter=None):
""" Return a sequence of IDs of IContentish and IFolderish sub-objects.
o Provide a filtered view onto 'objectIds', allowing only
"content space" objects to show through.
o Permission: Public (not publishable)
Returns -- List of object IDs
"""
def contentValues(filter=None):
""" Return a sequence of IContentish and IFolderish sub-objects.
o Provide a filtered view onto 'objectValues', allowing only
"content space" objects to show through.
o Permission: Public (not publishable)
Returns -- List of objects
"""
def listFolderContents(contentFilter=None):
""" Return a sequence of IContentish and IFolderish sub-objects,
filtered by the current user's possession of the View permission.
o Hook around 'contentValues' to let 'folder_contents' be protected.
o Duplicates 'skip_unauthorized' behavior of 'dtml-in'.
o Permission -- List folder contents
"""
class ISiteRoot(IFolderish):
""" Marker interface for the object which serves as the root of a site.
"""
__module__ = 'Products.CMFCore.interfaces'
#
# IOpaqueItems interfaces
#
class ICallableOpaqueItem(Interface):
""" Interface for callable opaque items.
o Opaque items are subelements that are contained using something that
is not an ObjectManager.
o On add, copy, move and delete operations, a marked opaque items
'manage_afterAdd', 'manage_afterClone' and 'manage_beforeDelete'
hooks get called if available. Unavailable hooks do not throw
exceptions.
"""
__module__ = 'Products.CMFCore.interfaces'
def __init__(obj, id):
"""Return the opaque item and assign it to 'obj' as attr with 'id'.
"""
def __call__():
"""Return the opaque items value.
"""
def getId():
"""Return the id of the opaque item.
"""
class ICallableOpaqueItemEvents(Interface):
"""CMF specific events upon copying, renaming and deletion.
"""
__module__ = 'Products.CMFCore.interfaces'
def manage_afterClone(item):
"""After clone event hook.
"""
def manage_beforeDelete(item, container):
"""Before delete event hook.
"""
def manage_afterAdd(item, container):
"""After add event hook.
"""
#
# Syndicatable interface
#
class ISyndicatable(Interface):
""" Filter content for syndication.
"""
__module__ = 'Products.CMFCore.interfaces'
def synContentValues():
""" Return a list of IDublinCore objects to be syndicated.
o For example, 'IFolderish' containers might returns a list of
recently-created or modified subobjects.
o Topics might return a sequence of objects from a catalog query.
"""