Example #1
0
def news_slug(slug):
    key = dictionary.get('apikey')

    if request.get_header('apikey') in key:
        row_data, msg = SampleController().get_news_detail_comment(slug)

        try:
            return Format().build(row_data, msg)
        except Exception as er:
            logger(str(er))
            abort(500, "Internal Server Error.")
    else:
        abort(401, 'Sorry, access denied.')
Example #2
0
def initialize_hw( test, dictionary ):
    i =  0
    for test_case in test:
        for category in test_case:
            if i == 0:
                top = category;
                if not dictionary.get(category):
                    dictionary[top] = {}
            elif i == 1:
                dimention = category
                if not dictionary[top].get(category):
                    dictionary[top][dimention] = {}
            elif i == 2:
                sub_category = category
                if not dictionary[top][dimention].get(category):
                    dictionary[top][dimention][sub_category] = {}
            i = i + 1
            i = i % 2
    return
Example #3
0
def initialize_hw(test, dictionary):
    i = 0
    for test_case in test:
        for category in test_case:
            if i == 0:
                top = category
                if not dictionary.get(category):
                    dictionary[top] = {}
            elif i == 1:
                dimention = category
                if not dictionary[top].get(category):
                    dictionary[top][dimention] = {}
            elif i == 2:
                sub_category = category
                if not dictionary[top][dimention].get(category):
                    dictionary[top][dimention][sub_category] = {}
            i = i + 1
            i = i % 2
    return
Example #4
0
def news_pagging():
    key = dictionary.get('apikey')

    if request.get_header('apikey') in key:
        perpage = 6
        if request.query.perpage:
            perpage = request.query.perpage

        page = 1
        if request.query.page:
            page = request.query.page

        row_data, msg = SampleController().get_news(int(perpage), int(page))

        try:
            return Format().build(row_data, msg)
        except Exception as er:
            logger(str(er))
            abort(500, "Internal Server Error.")
    else:
        abort(401, 'Sorry, access denied.')
Example #5
0
def initailize( test, dictionary ):
    i =  0
    for test_case in test:
        for category in test_case:
            if i == 0:
                top = category;
                if not dictionary.get(category):
                    dictionary[top] = {}
            elif i == 1:
                dimention = category
                if not dictionary[top].get(category):
                    dictionary[top][dimention] = {}
            elif i == 2:
                sub_category = category
                if not dictionary[top][dimention].get(category):
                    dictionary[top][dimention][sub_category] = {}
            elif i == 3:
                scenario = category
                if not dictionary[top][dimention][sub_category].get(category):
                    dictionary[top][dimention][sub_category][scenario] = {}
            i = i + 1
            i = i % 4
    return
Example #6
0
def initailize(test, dictionary):
    i = 0
    for test_case in test:
        for category in test_case:
            if i == 0:
                top = category
                if not dictionary.get(category):
                    dictionary[top] = {}
            elif i == 1:
                dimention = category
                if not dictionary[top].get(category):
                    dictionary[top][dimention] = {}
            elif i == 2:
                sub_category = category
                if not dictionary[top][dimention].get(category):
                    dictionary[top][dimention][sub_category] = {}
            elif i == 3:
                scenario = category
                if not dictionary[top][dimention][sub_category].get(category):
                    dictionary[top][dimention][sub_category][scenario] = {}
            i = i + 1
            i = i % 4
    return
Example #7
0
def news_sort(sort):
    key = dictionary.get('apikey')

    if request.get_header('apikey') in key:
        limit = 6
        if request.query.limit:
            limit = request.query.limit

        if sort == 'likes':
            row_data, msg = SampleController().get_news_likes(int(limit))
        elif sort == 'viwes':
            row_data, msg = SampleController().get_news_viwes(int(limit))
        else:
            row_data, msg = SampleController().get_news_most_comment(
                int(limit))

        try:
            return Format().build(row_data, msg)
        except Exception as er:
            logger(str(er))
            abort(500, "Internal Server Error.")
    else:
        abort(401, 'Sorry, access denied.')
Example #8
0
#!/usr/bin/env python
import dictionary

if dictionary.has("duck"):
    print "duck: " + dictionary.get("duck") + "."
if dictionary.has("goose"):
    print "goose: " + dictionary.get("goose") + "."
dictionary.set("lion", "Big cat")