retrieving the vocabulary, returns the vocabulary, not the actual vocabulary

2 messages Options
Embed this post
Permalink
pigeonflight () retrieving the vocabulary, returns the vocabulary, not the actual vocabulary
Reply Threaded More More options
Print post
Permalink
I'm working on a macro for an archetypes widget

The schema has the following:

my_schema['title'].vocabulary='getMyVocabulary'

When I add this to my custom macro:

      <input metal:fill-slot="widget_body"
             type="text"
             class="blurrable firstToFocus kss-myc-autocomplete"
             name=""
             value=""
             size="60"
             tal:attributes="name string:${fieldName};
                             id fieldName;
                             value value;
                             vocab field/Vocabulary;
                             size widget/size;
                             maxlength widget/maxlength|nothing;"
             />

I end up with the following output:

<input id="title" class="blurrable firstToFocus kss-myc-autocomplete" type="text" maxlength="255" vocab="[('g', 'g'), ('e', 'e'), ('t', 't'), ('M', 'M'), ('y', 'y'), ('V', 'V'), ('o', 'o'), ('c', 'c'), ('a', 'a'), ('b', 'b'), ('u', 'u'), ('l', 'l'), ('a', 'a'), ('r', 'r'), ('y', 'y')]" size="30" value="" name="title"/>

I'd like to retrieve the actual vocabulary, what am I missing?
On Thu, May 28, 2009 at 12:44 PM, david bain <[hidden email]> wrote:
Getting the old products
----------------------------------
old mycontractor code for Plone 2.0
http://david.post.alteroo.com/mycontractor.tgz

below is the login info
---------------------------------
server: homesource.com.au
dbdawg           9r2ZujEM

sudo su - mycontractor
cd zope



--
SplashStart - Professional Websites. Starting Now.
http://www.splashstart.com


------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users
Sascha Gottfried () Re: retrieving the vocabulary, returns the vocabulary, not the actual vocabulary
Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi David,

you did not show what should be in your vocab. Please provide it in your next reply.

Check the requirements - see field attribute 'vocabulary':
http://plone.org/documentation/manual/archetypes-developer-manual/fields/fields-reference#common-field-attributes

This means you have to pass the name of a method defined in the class for your content type that generates the vocabulary or you just pass something that is list of tuples or similar as defined in the manual. Try DisplayList at first - do not forget to import that first. If this works, try generating the vocabulary dynamically. Google for 'DisplayList'.


use of Displaylist() in a
sample config.py of your project
+++ config.py


from Products.Archetypes.public import DisplayList 
GLOBALS = globals() 
TOOLS = DisplayList(( 
    ('Harke', 'Harke'), 
    ('Spaten', 'Spaten'), 
    ('Hacket', 'Hacke'), 
    ('Besen', 'Besen'), 
    ('Karre', 'Karre'), 
    ))
and use the name 'TOOLS' in the vocabulary field of a widget in the schema definition:

+++ your content type class needs to import that first
from Products.YourClassName.config import TOOLS 

...
StringField('tools',
            vocabulary = TOOLS, 
            widget = MultiSelectionWidget(label = 'Tools',format='checkbox'), 
           ),

or in your style
my_schema['title'].vocabulary='TOOLS'

Links:
http://api.plone.org/Archetypes/1.3.10/public/frames/Archetypes/Archetypes.utils.DisplayList-class.html

david bain schrieb:
I'm working on a macro for an archetypes widget

The schema has the following:

my_schema['title'].vocabulary='getMyVocabulary'

When I add this to my custom macro:

      <input metal:fill-slot="widget_body"
             type="text"
             class="blurrable firstToFocus kss-myc-autocomplete"
             name=""
             value=""
             size="60"
             tal:attributes="name string:${fieldName};
                             id fieldName;
                             value value;
                             vocab field/Vocabulary;
                             size widget/size;
                             maxlength widget/maxlength|nothing;"
             />

I end up with the following output:

<input id="title" class="blurrable firstToFocus kss-myc-autocomplete" type="text" maxlength="255" vocab="[('g', 'g'), ('e', 'e'), ('t', 't'), ('M', 'M'), ('y', 'y'), ('V', 'V'), ('o', 'o'), ('c', 'c'), ('a', 'a'), ('b', 'b'), ('u', 'u'), ('l', 'l'), ('a', 'a'), ('r', 'r'), ('y', 'y')]" size="30" value="" name="title"/>

I'd like to retrieve the actual vocabulary, what am I missing?
On Thu, May 28, 2009 at 12:44 PM, david bain <[hidden email]> wrote:
Getting the old products
----------------------------------
old mycontractor code for Plone 2.0
http://david.post.alteroo.com/mycontractor.tgz

below is the login info
---------------------------------
server: homesource.com.au
dbdawg           9r2ZujEM

sudo su - mycontractor
cd zope



--
SplashStart - Professional Websites. Starting Now.
http://www.splashstart.com


------------------------------------------------------------------------------ Enter the BlackBerry Developer Challenge This is your chance to win up to $100,000 in prizes! For a limited time, vendors submitting new applications to BlackBerry App World(TM) will have the opportunity to enter the BlackBerry Developer Challenge. See full prize details at: http://p.sf.net/sfu/Challenge

_______________________________________________ Archetypes-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/archetypes-users

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time,
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
Archetypes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/archetypes-users