@auth.s3_requires_membership(1)
def twitter_channel():

    #try:
    #    import tweepy
    #except:
    #    session.error = T("tweepy module not available within the running Python - this needs installing for non-Tropo Twitter support!")
    #    redirect(URL(c="admin", f="index"))

    tablename = "%s_%s" % (module, resourcename)
    table = s3db[tablename]

    # CRUD Strings
    s3.crud_strings[tablename] = Storage(
        title_update = T("Edit Twitter account"),
        msg_record_modified = T("Twitter account updated"),
    )

    def prep(r):
        oauth_consumer_key = settings.msg.twitter_oauth_consumer_key
        oauth_consumer_secret = settings.msg.twitter_oauth_consumer_secret
        if not (oauth_consumer_key and oauth_consumer_secret):
           session.error = T("You should edit Twitter settings in models/000_config.py")
           return True
        oauth = tweepy.OAuthHandler(oauth_consumer_key,
                                   oauth_consumer_secret)

        if r.http == "GET" and r.method in ("create", "update"):
           # We're showing the form
           _s3 = session.s3
           try:
               _s3.twitter_oauth_url = oauth.get_authorization_url()
               _s3.twitter_request_key = oauth.request_token.key
               _s3.twitter_request_secret = oauth.request_token.secret
           except tweepy.TweepError:
               session.error = T("Problem connecting to twitter.com - please refresh")
               return True
           #table.pin.readable = True
           #table.pin.label = T("PIN number from Twitter (leave empty to detach account)")
           #table.pin.value = ""
           table.twitter_account.label = T("Current Twitter account")
           return True
        else:
           # Not showing form, no need for pin
           #table.pin.readable = False
           #table.pin.label = T("PIN") # won't be seen
           #table.pin.value = ""       # but let's be on the safe side
           pass
        return True
    #s3.prep = prep

    # Post-process
    def postp(r, output):
        if r.interactive:
            # Normal Action Buttons
            s3_action_buttons(r)
            # Custom Action Buttons for Enable/Disable
            table = r.table
            query = (table.deleted == False)
            rows = db(query).select(table.id,
                                    table.enabled,
                                    )
            restrict_e = [str(row.id) for row in rows if not row.enabled]
            restrict_d = [str(row.id) for row in rows if row.enabled]

            from s3 import s3_str
            s3.actions += [dict(label=s3_str(T("Enable")),
                                _class="action-btn",
                                url=URL(args=["[id]", "enable"]),
                                restrict = restrict_e),
                           dict(label=s3_str(T("Disable")),
                                _class="action-btn",
                                url = URL(args = ["[id]", "disable"]),
                                restrict = restrict_d),
                           ]
            if not s3task._is_alive():
                # No Scheduler Running
                s3.actions += [dict(label=s3_str(T("Poll")),
                                    _class="action-btn",
                                    url = URL(args = ["[id]", "poll"]),
                                    restrict = restrict_d)
                               ]

            #if isinstance(output, dict):
            #    if r.http == "GET" and r.method in ("create", "update"):
            #        rheader = A(T("Collect PIN from Twitter"),
            #                    _href=session.s3.twitter_oauth_url,
            #                    _target="_blank")
            #        output["rheader"] = rheader
        return output
    s3.postp = postp

    s3db.configure(tablename,
                   listadd = False,
                   deletable = False,
                   )

    return s3_rest_controller(deduplicate="", list_btn="")

# -----------------------------------------------------------------------------
Takes an xml_document and sends it as text.
dataset/ETHPy150Open sahana/eden/controllers/msg.py/twitter_channel--crossover with--dataset/ETHPy150Open jdswinbank/Comet/comet/protocol/base.py/ElementSender.send_xml