예제 #1
0
파일: account.py 프로젝트: teamwalkr/walkr
    def submit(self):
        ''' 
        This function validates the submitted registration form and creates a
        new user. Restricted to ``POST`` requests. If successful, redirects to 
        the result action to prevent resubmission.
        ''' 
        
        user = User(
            self.form_result['username'],
            self.form_result['password'],
            email=self.form_result['email'],
            fullname=self.form_result['fullname'],
        )


        Session.add(user) 
        Session.commit()
        '''
        msg = Message("*****@*****.**", self.form_result['email'], 
                      "Syriac Reference Portal registration")
        msg.plain = """%s, thank you for registering with the Syriac Reference
                       Portal. You can access your """ % self.form_result['username'] 
        msg.send()
        '''
        h.redirect(h.url(controller='account', action='result'))
예제 #2
0
파일: base.py 프로젝트: teamwalkr/walkr
 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
예제 #3
0
파일: helpers.py 프로젝트: serg9008/walkr
def delete_obj(obj):
    """
    Deletes any arbitrary object from the SQLAlchemy Session and cascades deletes to evaluations.

    :param obj: object to delete

    """
    Session.delete(obj)
    Session.flush()
예제 #4
0
def delete_obj(obj):
    """
    Deletes any arbitrary object from the SQLAlchemy Session and cascades deletes to evaluations.

    :param obj: object to delete

    """
    Session.delete(obj)
    Session.flush()
예제 #5
0
파일: base.py 프로젝트: serg9008/walkr
 def __call__(self, environ, start_response):
     """Invoke the Controller"""
     # WSGIController.__call__ dispatches to the Controller method
     # the request is routed to. This routing information is
     # available in environ['pylons.routes_dict']
     try:
         return WSGIController.__call__(self, environ, start_response)
     finally:
         Session.remove()
예제 #6
0
파일: helpers.py 프로젝트: serg9008/walkr
def get_user(username):
    """
    Returns the User object from the model.

    :rtype: :class:`inphosite.model.User`
    """
    user = Session.query(User).filter_by(username=username.lower()).first()
    return user
예제 #7
0
def get_user(username):
    """
    Returns the User object from the model.

    :rtype: :class:`inphosite.model.User`
    """
    user = Session.query(User).filter_by(username=username.lower()).first()
    return user
예제 #8
0
파일: helpers.py 프로젝트: serg9008/walkr
def update_obj(obj, attributes, params):
    """
    Updates any arbitrary object. Takes a list of attributes and a dictionary of update
    parameters. Checks if each key is in the list of approved attributes and then attempts
    to set it. If the object does not have that key, throw an HTTP 400 Bad Request

    :param obj: object to update
    :param attributes: list of approved attributes
    :param params: dictionary of update parameters 

    """
    for key in params.keys():
        if key in attributes:
            try:
                set_attribute(obj, key, params[key])
            except:
                abort(400)
    
    Session.flush()
예제 #9
0
def update_obj(obj, attributes, params):
    """
    Updates any arbitrary object. Takes a list of attributes and a dictionary of update
    parameters. Checks if each key is in the list of approved attributes and then attempts
    to set it. If the object does not have that key, throw an HTTP 400 Bad Request

    :param obj: object to update
    :param attributes: list of approved attributes
    :param params: dictionary of update parameters 

    """
    for key in params.keys():
        if key in attributes:
            try:
                set_attribute(obj, key, params[key])
            except:
                abort(400)

    Session.flush()
예제 #10
0
파일: helpers.py 프로젝트: serg9008/walkr
def fetch_obj(type, id, error=404, new_id=False):
    """
    Fetches the object with the given id from the collection of type type. If
    the object does not exist, throw an HTTP error (default: 404 Not Found).

    :param type: object type
    :type type: class in :mod:`inphosite.model`
    :param id: object id
    :type id: integer or None
    :param error: HTTP error code.
    :rtype: *type*
    """
    if id is None:
        abort(error)
    obj_q = Session.query(type)
    obj = obj_q.get(int(id))
    #else:
    #    obj = obj_q.filter(type.ID==int(id)).first()

    if obj is None:
        abort(error)
    return obj
예제 #11
0
def fetch_obj(type, id, error=404, new_id=False):
    """
    Fetches the object with the given id from the collection of type type. If
    the object does not exist, throw an HTTP error (default: 404 Not Found).

    :param type: object type
    :type type: class in :mod:`inphosite.model`
    :param id: object id
    :type id: integer or None
    :param error: HTTP error code.
    :rtype: *type*
    """
    if id is None:
        abort(error)
    obj_q = Session.query(type)
    obj = obj_q.get(int(id))
    #else:
    #    obj = obj_q.filter(type.ID==int(id)).first()

    if obj is None:
        abort(error)
    return obj