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


Python Page.get方法代码示例

本文整理汇总了Python中models.Page.get方法的典型用法代码示例。如果您正苦于以下问题:Python Page.get方法的具体用法?Python Page.get怎么用?Python Page.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Page的用法示例。


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

示例1: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
 def get(self, **kwargs): 
     admin = False 
     user =  self.current_user  
     page_id = kwargs.get('pageid')
     options_dict = {}
     try:
         pages = Page.get(user.pages)
         for p in pages:
             if p.id == page_id:
                 admin = True
                 page = p
                 widgets = Widget.all().filter('page =', page).filter('deleted = ', False).order('order')
                 options = Option.all().filter('type_reference =', page)
                 for option in options:
                     options_dict[option.name] = {'id': str(option.key().id()), 'value': option.value}
                 
     except:
         page = None
         widgets = None
         options_dict = None
     if admin:
         #page = Page.get_by_key_name(str(page_id))
         #add_app_url = 'https://www.facebook.com/add.php?api_key=a284fdd504b5191923362afabc0ea6c7&pages=1&page=141947329155355'
         upload_url = blobstore.create_upload_url('/upload')
         page_id = encrypt(page_id).encode('hex')
         self.render("app/edit.html", admin=True, page=page,upload_url=upload_url, page_id=page_id,widgets= widgets, options=options_dict) 
     else:
         self.redirect('/dashboard')
开发者ID:seedprod,项目名称:pagify,代码行数:30,代码来源:handlers.py

示例2: do_import

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def do_import():
    page = Page.get(request.form.get('page_key', ''))
    if not page or page.import_state != IMPORTING:
        return 'NO_IMPORTER' # We're done
    importer = Importer.gql('WHERE page=:1', page.key()).get()
    if not importer:
        # This requires a request to fetch the page and parse the URLs.
        # It also enqueues the next run.
        create_importer(page)
        return 'CREATED'
    if importer.urls:
        url = importer.urls.pop(0)
        parser = None
        try:
            resp = urlfetch.fetch(url, deadline=10)
            if resp.status_code == 200:
                parser = CSSParser()
                sheet = parser.parseString(resp.content, href=url)
                style = sheet.cssText
                importer.style += '\n\n/* Imported from %s */\n%s' % (url, style)
            else:
                raise Exception('Error fetching %s' % url)
        except Exception, e:
            import traceback
            importer.errors.append('Error importing %s' % url)
            logging.error('Error importing for Page %s from %s:\n%s\n%s', page.key().id(), url, e, traceback.format_exc())
        finally:
开发者ID:naiyt,项目名称:WebPutty,代码行数:29,代码来源:tasks.py

示例3: save_page

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def save_page(language, query, link, rank, title):
    try:
        pg = Page.create(language=language, query=query, link=link, rank=rank, title=title)
    except peewee.IntegrityError:
        pg = Page.get(Page.language == language, Page.link == link, Page.query == query)
        pg.language = language
        pg.rank = rank
        pg.title = title
        pg.save()
开发者ID:andrewhead,项目名称:StackSkim,代码行数:11,代码来源:google_tutorials.py

示例4: show_page

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def show_page(pagename):
    try:
        page = Page.get(Page.slug==str(pagename))
        if page is None:
            abort(404)
        else:
            return render_template('page.html', page=page)
    except:
        abort(404)
开发者ID:tommeagher,项目名称:Carboy,代码行数:11,代码来源:views.py

示例5: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
    def post(self):
        item = None
        vals = {}
        try:
            # get all the incoming values
            section = Section.get( self.request.get('section') )
            name = self.request.get('name').strip()
            title = self.request.get('title').strip()
            content = self.request.get('content')
            type = self.request.get('type')
            label_raw = self.request.get('label_raw').strip()
            attribute_raw = util.make_attr_raw_string(
                {
                    'index-entry'   : self.request.get('index_entry'),
                    'has-comments'  : self.request.get('has_comments'),
                    'comments-open' : self.request.get('comments_open'),
                    }
                ).strip()

            # some pre-processing of the input params
            if name == '':
                name = util.urlify(self.request.get('title'))

            if self.request.get('key'):
                item = Page.get( self.request.get('key') )
                item.section = section
                item.name = name
                item.title = title
                item.content = content
                item.type = type
                item.label_raw = label_raw
                item.attribute_raw = attribute_raw
            else:
                item = Page(
                    section = section,
                    name = name,
                    title = title,
                    content = content,
                    type = type,
                    label_raw = label_raw,
                    attribute_raw = attribute_raw,
                    )

            # update and save this page
            item.set_derivatives()
            item.put()
            # once saved, regenerate certain section properties
            section.regenerate()
            # also, check that this section doesn't have duplicate content
            Task( params={ 'section_key': str(section.key()), 'name': item.name }, countdown=30, ).add( queue_name='section-check-duplicate-nodes' )
            self.redirect('.')
        except Exception, err:
            vals['item'] = self.request.POST
            vals['err'] = err
            vals['sections'] = Section.all()
            vals['types'] = models.type_choices
            self.template( 'page-form.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:59,代码来源:page.py

示例6: get_page_object

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def get_page_object(page_id):
    """
    Retrieves a Page from a given page ID, getting page data from
    the API and saving the Page if it doesn't already exist in the DB.
    """
    try:
        return Page.get(Page.page_id == page_id)
    except DoesNotExist:
        data = get_raw_page_by_id(page_id)
        return Page.create(page_id=data['pageid'],
                           page_title=data['title'])
开发者ID:mplewis,项目名称:wikiwatcher,代码行数:13,代码来源:scraper.py

示例7: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
    def get(self):
        item = None
        if self.request.get('key'):
            item = Page.get( self.request.get('key') )

        vals = {
            'item' : item,
            'sections' : Section.all(),
            'types' : models.type_choices
            }
        self.template( 'page-form.html', vals, 'admin' );
开发者ID:ranginui,项目名称:kohacon,代码行数:13,代码来源:page.py

示例8: order_pages

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def order_pages(language, random_seed):

    ''' Random seed should be deterministic, but different for each language. '''
    random.seed(random_seed * hash(language))

    pages = (Page.select()
             .group_by(Page.link)
             .where(
                 Page.language == language,
                 Page.has_example == 1,
                 ))

    ids = [p.id for p in pages]
    random.shuffle(ids)
    ordered_pages = [Page.get(Page.id == id_) for id_ in ids]
    return ordered_pages
开发者ID:andrewhead,项目名称:StackSkim,代码行数:18,代码来源:order.py

示例9: get

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
    def get(self, page_title, revision=None):
        page_title = page_title.strip('/')
        user = self.authenticate_session_id()

        if not user:
            self.redirect("/login")
        elif revision is None:
            p = Page.get_newest(page_title)
            if p:
                self.render("edit.html", user=user.username, title=p.title, content=p.content)
        elif revision == "/new" or revision == "new":
            self.render("edit.html", user=user.username, title=page_title)
        else:
            revision = int(revision.strip('/'))
            p = Page.get(page_title, revision)
            self.render("edit.html", user=user.username, title=page_title, content=p.content)
开发者ID:danjl,项目名称:wikijust,代码行数:18,代码来源:main.py

示例10: _stats

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def _stats():
    if not (users.is_current_user_admin() or users.get_current_user().email().endswith('@fogcreek.com') or request.remote_addr in ['127.0.0.1', '71.190.247.30']):
        abort(404)

    user_count = GqlQuery('SELECT __key__ FROM UserSettings').count(None)
    site_count = GqlQuery('SELECT __key__ FROM Site WHERE example=false').count(None)
    now = datetime.now()
    days = list(reversed([now-timedelta(days) for days in range(14)]))
    day_views = [get_period_and_count('css:all', PeriodType.DAY, day) for day in days]
    day_users = [get_period_and_count('user:all', PeriodType.DAY, day) for day in days]
    day_sites = [get_period_and_count('site:all', PeriodType.DAY, day) for day in days]
    # overwrite today's cached numbers with the live count we just got from the database
    day_users[-1] = day_users[-1][0], user_count
    day_sites[-1] = day_sites[-1][0], site_count

    # get the top referrers
    period_type = PeriodType.DAY
    fetch_limit = 50
    query = LivecountCounter.all().order('-count')
    query.filter('period_type = ', period_type)
    query.filter('period = ', PeriodType.find_scope(period_type, datetime.now()))
    top_counters = query.fetch(fetch_limit)
    top_referrers = []
    for counter in top_counters:
        name = counter.name
        if name.startswith('css:page') and not name.startswith('css:page:www.webputty.net'):
            parts = name.split(':')
            page = None
            preview_size = 0
            published_size = 0
            try:
                page = Page.get(parts[3])
            except Exception:
                logging.warn("_stats counldn't find matching page: %s", parts[3])
            if page:
                preview_size = len(page.compressed_css(True))
                published_size = len(page.compressed_css(False))
            top_referrers.append((parts[2], counter.count, parts[3], preview_size, published_size))

    return render_template('_stats.html', user_count=user_count, site_count=site_count, day_views=day_views, day_users=day_users, day_sites=day_sites, top_referrers=top_referrers)
开发者ID:1ncnspcuous,项目名称:WebPutty,代码行数:42,代码来源:views.py

示例11: upload_style

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
def upload_style():
    page_key = request.form.get('page_key', None)
    if page_key:
        page = Page.get(page_key)
        page.upload_to_cdn()
    return 'OK'
开发者ID:naiyt,项目名称:WebPutty,代码行数:8,代码来源:tasks.py

示例12: post

# 需要导入模块: from models import Page [as 别名]
# 或者: from models.Page import get [as 别名]
 def post(self, **kwargs):
     user =  self.current_user
     admin = False
     method = kwargs.get('method')
     if method == 'deletewidget':
         key_name = self.request.get("wid")
         widget = Widget.get_by_key_name(key_name)
         if widget:
             widget.deleted = True
             widget.last_modified_by = user
         try:
             db.put(widget)
             self.response.out.write('True')
         except:
             self.response.out.write('False')
             
     if method == 'savepageorder':
         page_order = self.request.get('pageorder')
         page_order = page_order.split(',')
         batch = []
         for k,v in enumerate(page_order):
             widget = Widget.get_by_key_name(v)
             if widget:
                 widget.order = k
                 widget.last_modified_by = user
                 batch.append(widget)
         try:
             db.put(batch)
             self.response.out.write('True')
         except:
             self.response.out.write('False')
             
     if method == 'savewidget':
         page = Page.get_by_key_name(self.request.get('pageid'))
         key_name = self.request.get('wid')
         widget = Widget.get_by_key_name(key_name)
         if self.request.get('wtype') == 'embedly':
            fields = simplejson.loads(self.request.get('wcontents'))
            #get_embedly_code({'id':self.request.get('wid'),"url":fields['embedly_url'],"type":"embedly"})
            deferred.defer(get_embedly_code,{'id':self.request.get('wid'),"url":fields['embedly_url'],"type":"embedly"})
         if self.request.get('wtype') == 'googlemaps':
            fields = simplejson.loads(self.request.get('wcontents'))
            deferred.defer(get_embedly_code,{'id':self.request.get('wid'),"url":fields['googlemaps_link'],"type":"googlemaps"})
         if not widget:
             widget = Widget(key_name=key_name,
                             id = key_name,
                             type = self.request.get('wtype'),
                             name = self.request.get('wname'),
                             page = page,
                             contents = self.request.get('wcontents'),
                             last_modified_by = user
                            )
             fields = simplejson.loads(self.request.get('wcontents'))
             for k,v in fields.iteritems():
                 db_type = k.split('__')
                 try:
                     db_type = db_type[1]
                 except IndexError:
                     db_type = None
                 logging.info(db_type)
                 if db_type == 'text':
                     setattr(widget, k, db.Text(v))
                 else:
                     setattr(widget, k, v)
         else:
             widget.name = self.request.get('wname')
             widget.contents = self.request.get('wcontents')
             widget.last_modified_by = user
             fields = simplejson.loads(self.request.get('wcontents'))
             for k,v in fields.iteritems():
                 db_type = k.split('__')
                 try:
                     db_type = db_type[1]
                 except IndexError:
                     db_type = None
                 logging.info(db_type)
                 if db_type == 'text':
                     setattr(widget, k, db.Text(v))
                 else:
                     setattr(widget, k, v)
         
         try:
             db.put(widget)
             self.response.out.write('True')
         except:
             self.response.out.write('False')
     if method == 'saveoption':
         try:
             option = Option.get_by_id(int(self.request.get('id')))
         except:
             option = None
         if self.request.get('otype') == 'page':
             link = Page.get_by_key_name(self.request.get('opageid'))
         if not option:
             option = Option(
                             name = self.request.get('oname'),
                             value = self.request.get('ovalue'),
                             type = self.request.get('otype'),
                             type_reference = link
                            )
#.........这里部分代码省略.........
开发者ID:seedprod,项目名称:pagify,代码行数:103,代码来源:handlers.py


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