Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7573009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:04:21+00:00 2026-05-30T16:04:21+00:00

I am trying to fetch a Named Vocabulary and loop through its contents. Below

  • 0

I am trying to fetch a Named Vocabulary and loop through its contents. Below is the code I have so far.

def get_car_types(self):

    car_types = []

    vtool = getToolByName(self, 'portal_vocabularies')
    cars_vocab = vtool.getVocabularyByName('my.package.car_models')

    for terms in cars_vocab:
        print terms.value + ": " + terms.title

I get the following error:

AttributeError: 'int' object has no attribute 'startswith'

It points out that the error is somewhere around this line:

for terms in cars_vocab:

What could be the problem? How does one fetch a named vocabulary and loop through the values? I have been using this link.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T16:04:22+00:00Added an answer on May 30, 2026 at 4:04 pm

    I figured out another way to make it work. Below is the code.

    from Products.ATVocabularyManager import NamedVocabulary
    
    def get_car_types(self):        
    
            car_types = []        
            car_vocab = NamedVocabulary('my.package.car_models')
            car_terms = car_vocab.getDisplayList(self).items()
    
            for term in car_terms:
                car_types.append( (term[0], term[1]) )
    
            return car_types
    

    Thanks to all the guys who offered to answer my question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fetch wcf service from jquery. I have written below code
I have two tables as shown here . I am trying to fetch name
I'm trying to fetch and parse an XML-file through JavaScript. I don't control the
I'm trying to fetch some HTML from various blogs and have noticed that different
I have a integer named marbles, and am trying to save it into an
So I'm trying to fetch objects from core data. I have list of say
I'm trying to fetch a list of results for a search through Amazon API
Below is python code where I am trying to get reservations information from the
I have a productpart database containing a string property named 'type'. What I'm trying
I have a problem using jsoup what I am trying to do is fetch

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.