from decimal import Decimal
from zope.component import getUtility
from plone.registry.interfaces import IRegistry
from bda.plone.shop.interfaces import IShopArticleSettings
from bda.plone.shop.interfaces import IShopCartSettings
from bda.plone.shop.interfaces import IShopSettings
from bda.plone.shop.interfaces import IShopShippingSettings
from bda.plone.shop.interfaces import IShopTaxSettings
from bda.plone.shop.interfaces import INotificationTextSettings
from bda.plone.shop.interfaces import IPaymentTextSettings


def format_amount(val):
    val = val.quantize(Decimal('1.00'))
    if bool(val % 2):
        return str(val).replace('.', ',')
    return str(val.quantize(Decimal('1'))) + ',-'


def get_shop_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IShopSettings, check=False)


def get_shop_tax_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IShopTaxSettings, check=False)


def get_shop_article_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IShopArticleSettings, check=False)


def get_shop_cart_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IShopCartSettings, check=False)


def get_shop_shipping_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IShopShippingSettings, check=False)


def get_shop_notification_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(INotificationTextSettings, check=False)


def get_shop_payment_settings():
    reg = getUtility(IRegistry)
    return reg.forInterface(IPaymentTextSettings, check=False)

@@ -717,35 +717,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -747,39 +747,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -774,37 +774,24 @@
 ShopSettings
-, check=False
 )%0A%0A%0Adef get_
@@ -809,35 +809,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -839,39 +839,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -869,37 +869,24 @@
 pTaxSettings
-, check=False
 )%0A%0A%0Adef get_
@@ -908,35 +908,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -938,39 +938,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -972,37 +972,24 @@
 icleSettings
-, check=False
 )%0A%0A%0Adef get_
@@ -1008,35 +1008,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -1038,39 +1038,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -1069,37 +1069,24 @@
 CartSettings
-, check=False
 )%0A%0A%0Adef get_
@@ -1109,35 +1109,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -1139,39 +1139,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -1174,37 +1174,24 @@
 pingSettings
-, check=False
 )%0A%0A%0Adef get_
@@ -1218,35 +1218,36 @@
 ttings():%0A    re
-g =
+turn
  getUtility(IReg
@@ -1248,39 +1248,24 @@
 y(IRegistry)
-%0A    return reg
 .forInterfac
@@ -1291,29 +1291,16 @@
 Settings
-, check=False
 )%0A%0A%0Adef 
@@ -1338,11 +1338,12 @@
   re
-g =
+turn
  get
@@ -1364,23 +1364,8 @@
 try)
-%0A    return reg
 .for
@@ -1398,19 +1398,6 @@
 ings
-, check=False
 )%0A

Revert "dont check, if schemata have settings in the registry. this avoids errors like: KeyError: 'Interface defines a field , for which there is no record.'. got this problem when running an unrelated test, which was not possible, because some adapter called the registry settings, which were not set up in the test fixture"