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

  • SEARCH
  • Home
  • 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 4127068
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T00:06:56+00:00 2026-05-21T00:06:56+00:00

Here is the situation: I have an XML file with the menu hiearchy for

  • 0

Here is the situation:

I have an XML file with the menu hiearchy for my app in it. I can display the menu, but defining the callbacks in the XML file only returns strings.

The more defined problem:
I need a way to callback functions via a string. Yeah, there’s the

lambda x: pass

deal, but I’m not really sure that’s what I need.

  • 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-21T00:06:57+00:00Added an answer on May 21, 2026 at 12:06 am

    I need a way to callback functions via a string.

    From the comments to your question I understand that you’d like to do something like:

    # ...
    callback_str = getcallback_str() # e.g., 'self.logic.account_new'
    callback = eval_dottedname(self, callback_str)`
    

    In this case eval_dottedname() function could be implemented as:

    def eval_dottedname(obj, dottedname):
        if dottedname.partition(".")[0] != 'self': # or some other criteria
                                                   # to limit the context
            raise ValueError
        return reduce(getattr, dottedname.split('.')[1:], obj)
    

    A better approach would be to limit string callbacks to simple identifiers and use a dispatch table like stdlib’s cmd module:

      def dispatch(self, callback_str):
          return getattr(self, 'do_' + callback_str, self.default)()      
    
      def do_this(self):
          pass
    
      def do_that(self):
          pass
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my situation: I have my mvc-config.xml file for my web service set
Here is my situation: I have an application that use a configuration file. The
i have the following situation : with my function i get an XML file
Here's my situation: I am editing an application's CSS style sheet. I can ONLY
Here is my situation: I have a solution with three projects: 1) Silverlight App,
I have a situation here, I want to replicate an app which will look
Here's the situation: I have a client who's issued me an XML schema, and
Here's the situation: I have a label's text set, immediately followed by a response.redirect()
Here is the situation: I have been called upon to work with InstallAnywhere 8,
Here's the situation: we have an Oracle database we need to connect to to

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.