EduploneWebdidactics/Extensions Install.py,1.9.2.1,1.9.2.2

Nils Haagen <[email protected]> Sun, 07 Aug 2005 14:31:42 +0000
Newsgroups gmane.comp.web.zope.eduplone.cvs
Message-ID <[email protected]>
Update of /cvsroot/eduplone/EduploneWebdidactics/Extensions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16443/Extensions

Modified Files:
      Tag: janus
	Install.py 
Log Message:
using hierarchical vocabs and widget

Index: Install.py
===================================================================
RCS file: /cvsroot/eduplone/EduploneWebdidactics/Extensions/Install.py,v
retrieving revision 1.9.2.1
retrieving revision 1.9.2.2
diff -C2 -d -r1.9.2.1 -r1.9.2.2
*** Install.py	20 Jun 2005 20:55:05 -0000	1.9.2.1
--- Install.py	7 Aug 2005 14:31:40 -0000	1.9.2.2
***************
*** 18,21 ****
--- 18,26 ----
  from Products.ExternalMethod.ExternalMethod import manage_addExternalMethod
  
+ 
+ from Products.EduploneWebdidactics.data.wd_level import * 
+ from Products.EduploneWebdidactics.data.wd_knowtypes import * 
+ from Products.EduploneWebdidactics.data.wd_mediatypes import * 
+ 
  def install(self):
      out = StringIO()
***************
*** 45,104 ****
  def install_vocabularies(self, out):
      atvm=getToolByName(self,ATVOCABULARYTOOL)
  
!     for vkey in eduplone_vocabularies.keys():
!         # create vocabulary if it doesnt exist:
!         vocabname= "wd_%s" % vkey
!         if not hasattr(atvm, vocabname):
!             print >>out, "adding vocabulary %s" % vocabname
!             atvm.invokeFactory('SimpleVocabulary',vocabname)
!         vocab = atvm[vocabname]
!         for (ikey, value) in eduplone_vocabularies[vkey]:
!             if not hasattr(vocab, ikey):
!                 vocab.invokeFactory('SimpleVocabularyItem', ikey)
!                 vocab[ikey].setTitle(value)
! 
! 
! 
! 
! eduplone_vocabularies = {}
! 
! # CLASSIFICATION
! eduplone_vocabularies['classification'] = (
!     ('orientation', u'Orientierung'),
!     ('summary', u'Zusammenfassung'),
!     ('overview', u'Ueberblick'),
!     ('explanation', u'Erklaerung'),
!     ('example', u'Beispiel'),
!     ('action', u'Handlung'),
!     ('rule', u'Regel'),
!     ('procedure', u'Prozedur'),
!     ('checklist', u'Checkliste'),
!     ('source', u'Quelle'),
!     ('assignment', u'Aufgabe'),
!     ('question', u'Frage'),
! )
! 
! # LEVEL
! eduplone_vocabularies['level'] = (
!     ('easy', u'Leicht'),
!     ('medium', u'Mittel'),
!     ('expert', u'Schwer'),
! )
  
- eduplone_vocabularies['mediatype'] = (
-     ('pres_text', u'Praesentation - Text'),
-     ('pres_table', u'Praesentation - Tabelle'),
-     ('pres_graphic', u'Praesentation - Grafik'),
-     ('pres_animatedgraphic', u'Praesentation - animierte Grafik'),
-     ('pres_image', u'Praesentation - Bild'),
-     ('pres_video', u'Praesentation - Film/Video'),
-     ('pres_sound', u'Praesentation - Sound'),
-     ('interact_simulation', u'Interaktion - Simulation'),
-     ('interact_voting', u'Interaktion - Abstimmung'),
-     ('interact_rating', u'Interaktion - Bewertung'),
-     ('communication_chat', u'Kommunikation - Chat'),
-     ('communication_email', u'Kommunikation - E-Mail'),
-     ('communication_directmail', u'Kommunikation - interne Nachricht'),
-     ('communication_board', u'Kommunikation - Forum')
- )
  
--- 50,86 ----
  def install_vocabularies(self, out):
      atvm=getToolByName(self,ATVOCABULARYTOOL)
+         
+     atvm.invokeFactory('SimpleVocabulary', 'wd_level')
+     for (ikey, value) in vocab_wd_level:
+         atvm['wd_level'].invokeFactory('SimpleVocabularyItem', ikey)
+         atvm['wd_level'][ikey].setTitle(value)
+     print >>out, "adding vocabulary wd_level" 
+     
+     atvm.invokeFactory('TreeVocabulary', 'wd_classification')    
+     s=vocab_wd_classification
+     c=atvm.wd_classification
+     unpack(s,c)
  
!     atvm.invokeFactory('TreeVocabulary', 'wd_mediatype')    
!     s=vocab_wd_mediatype
!     c=atvm.wd_mediatype
!     unpack(s,c)
  
  
+ def create_item(i_key, i_val, i_curObject):
+     i_curObject.invokeFactory('TreeVocabularyItem', i_key)
+     i_curObject[i_key].setTitle(i_val)
+ 
+ def unpack(items, i_curObject):
+     for i in items:
+         i_key=i
+         i_val,i_sub=items[i_key]
+ 
+         create_item(i_key, i_val, i_curObject)
+         if i_sub != {}:
+             i_curObject=i_curObject[i_key]
+             unpack(i_sub, i_curObject)
+             i_curObject=i_curObject.aq_parent
+ 
+  
+  
\ No newline at end of file



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf