Bonjour,
Je fais un product et j'ai des petits soucis avec PropertyManager.
Lorsque je fais une instance, d'un type archetype que j'ai créé, dans l'install j'ai un message d'erreur.

En fait, je n'ai pas trouvé de doc, de faq ou de product suffisament détaillés pour m'en inspirer. (Zope book appendix, Zope develloper's guide et même http://docs.neuroinf.de/programming-plone/appendixA#1-3 devraient suffire mais apparement non....)

Si quelqu'un a des infos...(pdeoliveira ou senacle m'avaient donné des réponses que je n'ai pas su les exploitées (http://www.developpez.net/forums/sho...d.php?t=218440)

Je galère un peu mais j'y arriverai!
Merci bien,
biz+++


message d'erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
2006-10-12 11:24:01
failed:
Traceback (most recent call last):
 
  File "C:\Program Files\Plone 2\Data\Products\CMFQuickInstallerTool\QuickInstallerTool.py", line 322, in installProduct
    res=install(portal)
 
  File "C:\Program Files\Plone 2\Zope\lib\python\Products\ExternalMethod\ExternalMethod.py", line 225, in __call__
    try: return f(*args, **kw)
 
  File "C:\Program Files\Plone 2\Data\Products\GestionCourrier\Extensions\Install.py", line 25, in install
    new_id1 = folder.invokeFactory(id=id1, type_name=type_name)
 
  File "C:\Program Files\Plone 2\Data\Products\CMFCore\PortalFolder.py", line 408, in invokeFactory
    return pt.constructContent(type_name, self, id, RESPONSE, *args, **kw)
 
  File "C:\Program Files\Plone 2\Data\Products\CMFCore\TypesTool.py", line 932, in constructContent
    raise ValueError('No such content type: %s' % type_name)
 
ValueError: No such content type: DossierCourrier
Courrier.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
from Products.GestionCourrier.config import ARTICLE_GROUPS1
from Products.GestionCourrier.config import ARTICLE_GROUPS2
from Products.Archetypes.public import *
from Products.Archetypes.Marshall import PrimaryFieldMarshaller
from Products.CMFCore import CMFCorePermissions
from config import PROJECTNAME
from OFS.PropertyManager import PropertyManager
 
 
schema = BaseSchema +  Schema((
	StringField('Num_dpt',
		vocabulary=ARTICLE_GROUPS1,
		widget=SelectionWidget(label="Numero de departement"),
		required=1,
	),
	StringField('Type',
		vocabulary=ARTICLE_GROUPS2,
		widget=SelectionWidget(label="Type"),
		required=1,
	),
	IntegerField('Annee',
		default='06',
		widget=IntegerWidget(label="Annee"),
		required=1,
	),
	IntegerField('chrono',
		widget=IntegerWidget(label="Chrono"),
		#default_method="incrChrono",
		#accessor="DossierCourrier.getChrono",
		required=1,
	),
	StringField('Objet',
		widget=StringWidget(label="Objet"),
		required=1,
	),
	StringField('Destinataire',
		widget=StringWidget(label="Destinataire"),
		required=1,
	),
	FileField('Fichier',
		widget=FileWidget(label="Fichier"),
	),),
      marshall=PrimaryFieldMarshaller(),
	)
 
schema2 = BaseBTreeFolderSchema
 
class DossierCourrier(BaseBTreeFolder, PropertyManager):
	"""Un simple dossier"""
	allowed_content_types = ('Courrier',)
	Initial_view_name = 'folder_listing' 
	Default_view_method = 'folder_tabular_view'
 
	schema = schema2
 
	_properties=(
		{
		'id' : 'chrono',
		'type' : 'int'
		},)
		chrono=0
 
	__ac_permissions__ :
		('Manage properties', ('manage_addProperty',
			'manage_editProperties',
			'manage_delProperties',
			'manage_changeProperties',)), 
 
	actions = ({
        'id': 'view',
        'name': 'View',
        'action': 'string:${object_url}/folder_tabular_view',
        'permissions': (CMFCorePermissions.View,)
        },)
 
registerType(DossierCourrier, PROJECTNAME)
 
class Courrier(BaseContent):
 
	schema = schema
 
	actions = ({
		'id': 'view',
		'name': 'View',
		'action': 'string:${object_url}/courrier_view',
		'permissions': (CMFCorePermissions.View,)
	},)
 
registerType(Courrier, PROJECTNAME)
Extensions/Install.py
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
from Products.Archetypes.public import listTypes
from Products.Archetypes.Extensions.utils import installTypes, install_subskin
from Products.GestionCourrier.config import PROJECTNAME, GLOBALS
from Products.CMFCore.utils import getToolByName
 
from StringIO import StringIO
 
def install(self):
	out = StringIO()
	installTypes(self, out, listTypes(PROJECTNAME), PROJECTNAME)
 
	install_subskin(self, out, GLOBALS)
 
	#initialisation
	portal = getToolByName(self, "portal_url").getPortalObject()
	type_name="DossierCourrier"
	title1="Courrier Emis"
	title2="Courrier Recu"
 
	#A changer si besoin est
	folder=portal
	id1 = folder.generateUniqueId(type_name)
	id2 = folder.generateUniqueId(type_name)
 
	new_id1 = folder.invokeFactory(id=id1, type_name=type_name) 
	new_id2 = folder.invokeFactory(id=id2, type_name=type_name) 
 
	if new_id1 is None or new_id1 == "":
		new_id1 = id1
	if new_id2 is None or new_id2 == "":
		new_id2 = id2
 
	obj1 = getattr(folder, new_id1)
	obj2 = getattr(folder, new_id2)
 
	#Nous devons renommer l'objet pour avoir un id lisible
	kwargs = {"title": title1}
	obj1.edit(**kwargs)
	new_id1 = obj1._renameAfterCreation()
 
	kwargs = {"title": title2}
	obj2.edit(**kwargs)
	new_id2 = obj2._renameAfterCreation()
 
	out.write("Successfully installed %s." % PROJECTNAME)
	return out.getvalue()