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 8543895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:25:12+00:00 2026-06-11T12:25:12+00:00

OK, I allready have read all questions about class method decorating, but my case

  • 0

OK, I allready have read all questions about class method decorating, but my case not like them.

def safe_db(foo):
    def _inner(*args, **kwargs):
        try:
            foo(args, kwargs)
            return True
        except Exception as e:
            log.error(e.message)
            print e.message
            return False
    return _inner


class BaseDB(object):
    def __init__(self):
        self.connection = Connection()
        self.db = self.connection.goobi
        self.table = None

    @safe_db
    def create(self, **data):
        self.table.insert(data)

    def update(self, where, **data):
        try:
            self.table.update(where, {'$set': data})
            return True
        except Exception as e:
           log.error(e.message)
           print e.message
           return False

And then I try call method create from inherited class User:

u = User()
u.create(email='i@example.com', password='secrete')

I get exception:

2012-09-08 18:17:18,230 ERROR [hairs.model.user][worker 2] create() takes exactly 1      argument (2 given)
    create() takes exactly 1 argument (2 given)

I cant understand how I can decorate class methods of BaseDB, or how I can make exceptions catch and logging less painfull ?

  • 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-06-11T12:25:13+00:00Added an answer on June 11, 2026 at 12:25 pm

    You have an error in your decorator:

    def safe_db(foo):
        def _inner(*args, **kwargs):
            try:
                foo(*args, **kwargs)   # fixed line
                return True
            except Exception as e:
                log.error(e.message)
                print e.message
                return False
        return _inner
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read more than 3 questions here in stackoverflow about this, but all
I have read lots of questions and answers about this issue on StackOverflow, but
I have already read all the previous similar posts but I couldn't find a
Last week i read about liquibase quick start and all the related tutorials but
I've read several different questions from SO about this already but still haven't been
After all what I have read about Dependency Injection and IoC I have decided
I just want what my title says.I have already read all the previous similar
I have already read some posts, but no one helped me with my problem.
I've read all the SO questions, the Coding Horror articles, and Googled my brains
I'd like to have access to the bytecode that is currently running or about

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.