-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
72 lines (53 loc) · 1.67 KB
/
README.txt
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
Introduction
============
This product is designed to make your life easier when making
workflow applications.
We've come across situations where we need more complex control
over specific fields during each workflow state.
supported field attributes
-required
-validators
-write_permission
-read_permission
How to do it
================
All you need to do is have your content type implement IFieldWorkflowEnabled
and provide the desired workflow settings under each field.
Example
========================
from Products.Archetypes.atapi import *
from zope.interface import implements
import interfaces
from example.config import *
from uwosh.fieldworkflow.interfaces import IFieldWorkflowEnabled
schema = Schema((
IntegerField(
name='numberOfWheels',
widget=StringField._properties['widget'](
label="Number of wheels",
),
searchable=True,
#this is how you would set workflow changes to fields
workflow_settings={
"published" :{
"required": True,
"validators": ("isNumeric",)
}
}
),
),
)
CarSchema = BaseSchema.copy() + schema.copy()
class Car(BaseContent, BrowserDefaultMixin):
#required to make this work!
implements(interfaces.ICar, IFieldWorkflowEnabled)
#set if you would like to validate on transitions... Required attribute
validate_on_transition = True
#set to fine tune what transitions you would like to validate on
transitions_to_validate_on = ["submit", "publish"]
#used to handle your errors the way you want.
def validation_error_handler(self, error):
pass
meta_type = portal_type = 'Car'
schema = ExpertSchema
registerType(Car, PRODUCT_NAME)