예제 #1
0
파일: loadable.py 프로젝트: Go3Media/merlin
 def run(self, message):
     m = self.match(message, self.commandre)
     if m is None:
         if self.match(message, self.helpre) is not None:
             self.help(message)
         return
     command = m.group(1)
     try:
         access = self.check_access(message)
         if access is None:
             raise UserError
         params = self.check_params(command)
         if params is None:
             raise ParseError
         self.execute(message, access, params)
         session = Session()
         session.add(Command(command_prefix = message.get_prefix(),
                             command = self.name,
                             command_parameters = message.get_msg()[len(self.name)+1:],
                             nick = message.get_nick(),
                             username = "" if access is True else access.name,
                             hostname = message.get_hostmask(),
                             target = message.get_chan() if message.in_chan() else message.get_nick(),))
         session.commit()
     except PNickParseError:
         message.alert(self.PParseError)
     except UserError:
         message.alert(self.AccessError)
     except PrefError:
         message.alert(self.PrefError)
     except ChanParseError, e:
         message.alert(self.ChanError%e)
예제 #2
0
파일: loadable.py 프로젝트: berten/merlin
    def run(self, request, **kwargs):
        try:
            user, cookie, key, planet_id = self.router(request)
            response = self.execute(request, user, **kwargs)

            session = Session()
            session.add(
                PageView(
                    page=self.name,
                    full_request=request.get_full_path(),
                    username=user.name,
                    session=key,
                    planet_id=user.planet.id if user.planet else None,
                    hostname=request.META['REMOTE_ADDR'],
                ))
            session.commit()

            if cookie is not None:
                response.set_cookie(SESSION_KEY,
                                    cookie,
                                    expires=request.session.expire)

            if planet_id is False:
                response.delete_cookie(PLANET_KEY)
            elif planet_id is not True:
                response.set_cookie(PLANET_KEY,
                                    planet_id,
                                    expires=datetime.now() +
                                    timedelta(days=65))

            return response

        except UserError, e:
            return self.login_page(request, str(e))
예제 #3
0
파일: loadable.py 프로젝트: munin/merlin
 def run(self, message):
     m = self.match(message, self.commandre)
     if m is None:
         if self.match(message, self.helpre) is not None:
             self.help(message)
         return
     command = m.group(1)
     
     try:
         route, subcommand, user, params = self.router(message, command)
         
         route(message, user, params)
         
         session = Session()
         session.add(Command(command_prefix = message.get_prefix(),
                             command = self.name,
                             subcommand = subcommand,
                             command_parameters = message.get_msg()[len(self.name)+1:].strip(),
                             nick = message.get_nick(),
                             username = "" if user is True else user.name,
                             hostname = message.get_hostmask(),
                             target = message.get_chan() if message.in_chan() else message.get_nick(),))
         session.commit()
         session.close()
         
     except PNickParseError:
         message.alert(self.PParseError)
     except UserError:
         message.alert(self.AccessError)
     except PrefError:
         message.alert(self.PrefError)
     except ChanParseError, e:
         message.alert(self.ChanError%e)
예제 #4
0
파일: loadable.py 프로젝트: munin/merlin
 def run(self, request, **kwargs):
     user = request.session.user
     
     try:
         if self.check_access(user) is not True:
             raise UserError
         
         response = self.execute(request, user, **kwargs)
         
         session = Session()
         session.add(PageView(page = self.name,
                              full_request = request.get_full_path(),
                              username = user.name,
                              session = request.session.key,
                              hostname = request.get_host(),))
         session.commit()
         
         return response
     
     except UserError:
         return render("login.tpl", request, msg="F**k off.")
예제 #5
0
    def run(self, message):
        m = self.match(message, self.commandre)
        if m is None:
            if self.match(message, self.helpre) is not None:
                self.help(message)
            return
        command = m.group(2)

        try:
            route, subcommand, user, params = self.router(message, command)

            route(message, user, params)

            session = Session()
            session.add(
                Command(
                    command_prefix=message.get_prefix(),
                    command=self.name,
                    subcommand=subcommand,
                    command_parameters=self.hide_passwords(
                        self.name,
                        message.get_msg()[len(m.group(1)) + 1:].strip()),
                    nick=message.get_nick(),
                    username="" if user is True else user.name,
                    hostname=message.get_hostmask(),
                    target=message.get_chan()
                    if message.in_chan() else message.get_nick(),
                ))
            session.commit()
            session.close()

        except PNickParseError:
            message.alert(self.PParseError)
        except UserError:
            message.alert(self.AccessError)
        except PrefError:
            message.alert(self.PrefError)
        except ChanParseError, e:
            message.alert(self.ChanError % e)