示例#1
0
    def get(self, account=None):
        # Verify get() call is valid
        if self.scope == 'account':
            if account is None:
                raise ValueError(
                    'Account option requires the "account" parameter')

            if not self._validate_account(account):
                raise ValueError('Invalid value for "account" parameter: %r' %
                                 account)

        if self.scope == 'server' and account is not None:
            raise ValueError(
                "Server option can't be called with the \"account\" parameter")

        # Load option from database
        option, _ = ConfigurationOption.get_or_create(account=account or 0,
                                                      key=self.key,
                                                      defaults={
                                                          'value':
                                                          self._pack(
                                                              self.default),
                                                      })

        return self._clone(option)
示例#2
0
    def get(self, account=None):
        # Verify get() call is valid
        if self.scope == 'account':
            if account is None:
                raise ValueError('Account option requires the "account" parameter')

            if not self._validate_account(account):
                raise ValueError('Invalid value for "account" parameter: %r' % account)

        if self.scope == 'server' and account is not None:
            raise ValueError("Server option can't be called with the \"account\" parameter")

        # Load option from database
        option, _ = ConfigurationOption.get_or_create(
            account=account or 0,
            key=self.key,

            defaults={
                'value': self._pack(self.default),
            }
        )

        return self._clone(option)