def getCurrencies(self):
     utility = getUtility(ICurrencyUtility)
     currencies = []
     selected_currency = utility.getActiveCurrency()
     active_currencies = utility.getActiveCurrencies()
     for currency in active_currencies:
         currencies.append({'id': currency,
                            'title': _(utility.getCurrencyName(currency)),
                            'selected': (currency == selected_currency)})
     return currencies
 def setProperties(self):
     context = aq_inner(self.context)
     utils = getToolByName(context, 'plone_utils')
     utility = self.getUtility()
     
     for currency in currency_list.keys():
         if self.request.has_key(currency):
             utility.registerFactor(currency, self.request.get(currency, 1), context)
     
     props = getToolByName(context, 'portal_properties').currency_properties
     for property in self.properties:
         props._setPropValue(property, self.request.get(property, ''))
     utils.addPortalMessage(_(u'Properties saved'))
    def __call__(self):
        self.request.set('disable_border', True)
        
        utility = self.getUtility()
        if self.request.form.has_key('currency_update'):
            utility.update(self.context)
            utils = getToolByName(self.context, 'plone_utils')
            utils.addPortalMessage(_(u'Factors updated'))
        elif self.request.form.has_key('currency_save'):
            self.setProperties()

        props = getToolByName(self.context, 'portal_properties').currency_properties
        for property in self.properties:
            self.values[property] = props.getProperty(property, '')
        
        for currency in currency_list.keys():
            self.values[currency] = utility.getFactor(currency, self.context)
        
        return self.template()
 def getCurrencies(self):
     currencies = [{'id': id, 
                    'name': translate(_(currency[CURRENCY_NAME]), context=self.request)} for id, currency in currency_list.items()]
     currencies.sort(cmp=lambda x, y: cmp(x['name'],y['name']))
     return currencies