当前位置: 首页>>代码示例>>Python>>正文


Python models.DBSession类代码示例

本文整理汇总了Python中penelope.core.models.DBSession的典型用法代码示例。如果您正苦于以下问题:Python DBSession类的具体用法?Python DBSession怎么用?Python DBSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DBSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_board_changed

    def on_board_changed(self, data):
        # cleanup data - make sure we will not save empty tasks
        self.notify_redis("columns", {"value": data}, notify_me=False)

        for col in data:
            to_remove = []
            try:
                del col['$$hashKey'] # angular id that shouldn't be stored
            except KeyError:
                pass
            for n, task in enumerate(col['tasks']):
                if not task:
                    continue
                if not 'id' in task:
                    to_remove.append(n)
                try:
                    del task['$$hashKey'] # angular id that shouldn't be stored
                except KeyError:
                    pass
            to_remove.reverse()
            for n in to_remove:
                col['tasks'].pop(n)
        with transaction.manager:
            board = DBSession().query(KanbanBoard).get(self.board)
            board.json = dumps(data)
开发者ID:getpenelope,项目名称:penelope.core,代码行数:25,代码来源:kanbanboard.py

示例2: view_home

def view_home(request):
    """
    Default home view
    """
    fanstatic_resources.dashboard_home.need()

    session = DBSession()
    user = request.authenticated_user
    projects = session.query(Project)

    my_projects = projects\
                  .filter(Project.users_favorite(user))\
                  .order_by(Project.customer_id).all()

    my_projects = request.filter_viewables(my_projects)

    active_projects = set(projects.filter(Project.active))
    active_projects = sorted(request.filter_viewables(active_projects.difference(my_projects)), key=unicodelower)

    listings = []
    listing_columns = 4
    listings.append({'title': 'Active projects',
                     'projgroups': tuple(chunks(tuple(active_projects), listing_columns)),})
    kanbanboards = user.kanban_boards

    return {
            'my_projects': my_projects,
            'kanbanboards': kanbanboards,
            'listings': listings,
            'can_see_kanbanboards':  request.has_permission('listing', KanbanBoard),
            'get_application_link': get_application_link,
            }
开发者ID:getpenelope,项目名称:penelope.core,代码行数:32,代码来源:views.py

示例3: get_project_by_name

def get_project_by_name(request, project_name):
    """
    This method search for project by name
    """
    session = DBSession()

    if not isinstance(project_name, basestring):
        return {
                'status:': False,
                'message': u'Project name parameter must be a string!',
                }

    try:
        project = session.query(Project).filter_by(name=project_name).one()
    except orm_exc.NoResultFound:
        return {
                'status': False,
                'message': u'No project found in db for %s name' % project_name,
                }

    return {
            'status': True,
            'message': u'Project found.',
            'name': project.name,
            'id': project.id,
            'customer': project.customer.name,
            'applications': [x.name for x in project.applications],
            'customer_requests': [(x.id, x.name,) for x in project.customer_requests],
            }
开发者ID:getpenelope,项目名称:penelope.core,代码行数:29,代码来源:api.py

示例4: create_initial_application_acl

def create_initial_application_acl(mapper, connection, target):
    if target.application_type == SVN:
        acl_rules = [
                    ('internal_developer', 'edit'),
                    ('internal_developer', 'view'),
                    ('external_developer', 'edit'),
                    ('external_developer', 'view'),
                    ]
    else:
        acl_rules = [
                    ('internal_developer', 'view'),
                    ('external_developer', 'view'),
                    ('secretary', 'view'),
                    ('secretary', 'edit'),
                    ]

    if target.application_type == 'trac':
        acl_rules.append(('customer', 'view'))

    for role_id, permission_name in acl_rules:
        acl = DBSession.query(ApplicationACL).get((target.id, role_id, permission_name))
        if not acl:
            acl = ApplicationACL(application_id=target.id,
                                 role_id=role_id,
                                 permission_name=permission_name)
            DBSession.add(acl)
        else:
            # XXX this should not happen.
            pass
开发者ID:getpenelope,项目名称:penelope.core,代码行数:29,代码来源:dashboard.py

示例5: filter_stream

    def filter_stream(self, req, method, filename, stream, data):
        """Return a filtered Genshi event stream, or the original unfiltered
        stream if no match.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.

        See the Genshi documentation for more information.
        """
        if filename == 'ticket.html':
            ticket = data['ticket']
            if ticket.exists:
                if req.perm.has_permission('SENSITIVE_VIEW'):
                    qry = DBSession().query(CustomerRequest)
                    if not qry.get(ticket.values.get('customerrequest')).active:
                        div = tag.div(
                            tag.div(
                                tag.strong(u'Heads up! '),
                                tag.span(u'This ticket is assigned to an inactive customer request.',),
                                class_="alert alert-info"),
                            id='inactive_cr_ticket')
                        return stream | Transformer("//div[@id='ticket']").before(div)
        return stream
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:25,代码来源:plugins.py

示例6: get_user_by_email

def get_user_by_email(request, email):
    """
    This method search for user using his email address
    """
    session = DBSession()
    if not isinstance(email, basestring):
        return {
                'status:': False,
                'message': u'Email parameter must be a string!',
                }
    try:
        user = session.query(User).filter_by(email=email).one()
    except orm_exc.NoResultFound:
        return {
                'status': False,
                'message': u'No user found in db for %s mail address' % email,
                }

    return {
            'status': True,
            'message': u'User found.',
            'email': user.email,
            'login': user.login,
            'openids': [x.openid for x in user.openids]
            }
开发者ID:getpenelope,项目名称:penelope.core,代码行数:25,代码来源:api.py

示例7: get_user_by_openid

def get_user_by_openid(request, openid):
    """
    This method search for user using one of the possible user openids
    """
    session = DBSession()

    if not isinstance(openid, basestring):
        return {
                'status:': False,
                'message': u'Openid parameter must be a string!',
                }

    try:
        user = session.query(User).join('openids').filter_by(openid=openid).one()
    except orm_exc.NoResultFound:

        return {
                'status': False,
                'message': u'No user found in db for %s openid' % openid,
                }

    return {
            'status': True,
            'message': u'User found.',
            'email': user.email,
            'login': user.login,
            'openids': [x.openid for x in user.openids],
            }
开发者ID:getpenelope,项目名称:penelope.core,代码行数:28,代码来源:api.py

示例8: activate_iteration

def activate_iteration(context, request):
    docid = request.params.get('docid')
    if not docid:
        return view_iterations(context, request, validation_error=u'Missing document_id')

    #query = gdata.spreadsheet.service.CellQuery()

    #first take project names
    #query['min-col'] = '3'
    #query['max-col'] = '3'
    #query['min-row'] = '5'
    #cr_raw = get_cell_values(request, query)

    session = DBSession()

    #deactivate all CR
    #for cr in session.query(CustomerRequest):
    #    cr.active = False

    #activate selected CR
    #cr_ids = set([item for sublist in [a.split(',') for a in cr_raw] for item in sublist])
    #crs = session.query(CustomerRequest).filter(CustomerRequest.id.in_(cr_ids))
    #for cr in crs:
    #    cr.active = True

    gc = session.query(GlobalConfig).get(1)
    gc.active_iteration_url = docid

    return manage_iterations(context,request)
开发者ID:getpenelope,项目名称:penelope.core,代码行数:29,代码来源:views.py

示例9: get_customer_by_name

def get_customer_by_name(request, customer_name):
    """
    This method search for customer by name
    """
    session = DBSession()

    if not isinstance(customer_name, basestring):
        return {
                'status:': False,
                'message': u'Customer name parameter must be a string!',
                }

    try:
        customer = session.query(Customer).filter_by(name=customer_name).one()
    except orm_exc.NoResultFound:
        return {
                'status': False,
                'message': u'No customer found in db for %s name' % customer_name,
                }

    return {
            'status': True,
            'message': u'Customer found.',
            'name': customer.name,
            'projects': [x.name for x in customer.projects],
            }
开发者ID:getpenelope,项目名称:penelope.core,代码行数:26,代码来源:api.py

示例10: test_get_user_by_attribute

 def test_get_user_by_attribute(self):
     session = DBSession()
     user = User(email=u'[email protected]')
     session.add(user)
     transaction.commit()
     #Get the user by email
     resp = self.proxy.get_user_by_email('[email protected]')
     self.assertEqual(resp['email'], u'[email protected]')
开发者ID:getpenelope,项目名称:penelope.core,代码行数:8,代码来源:test_api.py

示例11: test_get_user_by_openid

    def test_get_user_by_openid(self):
        session = DBSession()
        user = User(email=u'[email protected]')
        user.add_openid(u'[email protected]')
        session.add(user)
        transaction.commit()

        resp = self.proxy.get_user_by_openid('[email protected]')
        self.assertTrue(u'[email protected]' in resp['openids'])
开发者ID:getpenelope,项目名称:penelope.core,代码行数:9,代码来源:test_api.py

示例12: Environment_get_known_users

 def Environment_get_known_users(self, cnx=None):
     project_id = self.config.get('por-dashboard', 'project-id')
     project = None
     if project_id:
         db = DBSession()
         project = db.query(Project).get(project_id)
         for user in db.query(User).all():
             if user.roles_in_context(project):
                 yield user.login, user.fullname, user.email
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:9,代码来源:monkey.py

示例13: test_get_customer_by_name

    def test_get_customer_by_name(self):
        customer_name = u'A rich customer'
        session = DBSession()
        customer = Customer(name=customer_name)
        session.add(customer)
        transaction.commit()

        resp = self.proxy.get_customer_by_name(customer_name)
        self.assertEqual(resp['name'], customer_name)
开发者ID:getpenelope,项目名称:penelope.core,代码行数:9,代码来源:test_api.py

示例14: get_permission_groups

 def get_permission_groups(self, username):
     # TODO: work only for por/trac on the same wsgi stack
     project_id = self.env.config.get('por-dashboard', 'project-id')
     if project_id:
         project = DBSession().query(Project).get(project_id)
         user = DBSession().query(User).filter_by(email=username).first()
         if user:
             return list(user.roles_in_context(context=project))
     return list() 
开发者ID:getpenelope,项目名称:penelope.trac,代码行数:9,代码来源:user.py

示例15: autoregister

def autoregister(profile):
    session = DBSession()
    chars = string.letters + string.digits
    password = ''.join(choice(chars) for _ in range(9))
    user = User(fullname = profile.get('displayName'),
                email = profile.get('emails')[0])
    user.set_password(password)
    user.add_openid(profile.get('accounts')[0].get('username'))
    session.add(user)
    return user
开发者ID:getpenelope,项目名称:penelope.core,代码行数:10,代码来源:views.py


注:本文中的penelope.core.models.DBSession类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。