Ejemplo n.º 1
0
class ServicePolls(SilvaService):
    """Service that manages poll data
    """
    grok.implements(IServicePolls)

    meta_type = 'Silva Poll Service'
    default_service_identifier = 'service_polls'
    silvaconf.icon('ServicePolls.png')

    manage_options = ({
        'label': 'Settings',
        'action': 'manage_settings'
    }, ) + SilvaService.manage_options

    security = ClassSecurityInfo()

    _store_cookies = True
    _automatically_hide_question = True

    def _init_database(self):
        self.db = DB()

    def create_question(self, question, answers):
        return self.db.create(question, answers)

    def get_question(self, qid):
        return self.db.get(qid).question

    def set_question(self, qid, question):
        return self.db.set_question(qid, question)

    def get_answers(self, qid):
        return self.db.get(qid).answers

    def set_answers(self, qid, answers):
        return self.db.set_answers(qid, answers)

    def get_votes(self, qid):
        return self.db.get(qid).votes

    def vote(self, qid, index):
        self.db.vote(qid, index)

    def automatically_hide_question(self):
        return self._automatically_hide_question

    def store_cookies(self):
        return self._store_cookies
Ejemplo n.º 2
0
class ServicePolls(SilvaService):
    """Service that manages poll data
    """
    grok.implements(IServicePolls)

    meta_type = 'Silva Poll Service'
    default_service_identifier = 'service_polls'
    silvaconf.icon('ServicePolls.png')

    manage_options = (
        {'label':'Settings', 'action':'manage_settings'},
        ) + SilvaService.manage_options

    security = ClassSecurityInfo()

    _store_cookies = True
    _automatically_hide_question = True

    def _init_database(self):
        self.db = DB()

    def create_question(self, question, answers):
        return self.db.create(question, answers)

    def get_question(self, qid):
        return self.db.get(qid).question

    def set_question(self, qid, question):
        return self.db.set_question(qid, question)

    def get_answers(self, qid):
        return self.db.get(qid).answers

    def set_answers(self, qid, answers):
        return self.db.set_answers(qid, answers)

    def get_votes(self, qid):
        return self.db.get(qid).votes

    def vote(self, qid, index):
        self.db.vote(qid, index)

    def automatically_hide_question(self):
        return self._automatically_hide_question

    def store_cookies(self):
        return self._store_cookies
Ejemplo n.º 3
0
 def _init_database(self):
     self.db = DB()
Ejemplo n.º 4
0
 def _init_database(self):
     self.db = DB()