def start_instance_get(self, template_arguments): template_arguments.update( {'post_address': StartInstancePost.link_info.getPageLink()}) keywords = request.GET.keywords regions = parseString(request.GET.regions, default='{}') instanceSetupCode = parseString(request.GET.instance_setup_code, default='') template_arguments.update({ 'home_link': getHomeLink(Configuration.PROJECT_NAME), 'keywords': keywords, 'regions': regions, 'instance_setup_code': instanceSetupCode, 'max_geographical_filters': Configuration.TWITTER_MAX_GEO_FILTERS }) error = request.GET.error if len(error) > 0: template_arguments.update({'error': error}) return template('instance-start.tpl', template_arguments)
def func(templateArguments, instance): dataType = parseString(request.GET.type,['tweet','user']) start_epoch = parseInteger(request.GET.start_epoch) end_epoch = parseInteger(request.GET.end_epoch) page_num = parseInteger(request.GET.page) place_id = parseInteger(request.GET.place_id) provider_id = parseInteger(request.GET.provider_id) projection_type = parseString(request.GET.projection_type) followee = parseInteger(request.GET.followee) cache_id = GeocodeResultAbstract.buildCacheId(provider_id, place_id) if dataType is None: return redirect_problem('type is a required argument') if page_num is None: page_num = 0 data = [] if dataType == 'tweet': tweets = readTweetsFromCache(None, instance, cache_id, start_epoch, end_epoch, page_num, TwitterCachePage.PAGE_SIZE_FULL_DATA) if tweets is not None: for tweet in tweets: assert isinstance(tweet, Tweet) userHtml = UserInformationPage.getPageLinkImage(instance, tweet.user, target='_self') data.append([ tweet.created_at, userHtml, tweet.user.location_text, tweet.text ]) elif dataType == 'user': if len(projection_type) == 0: projection = None pageSize = TwitterCachePage.PAGE_SIZE_FULL_DATA elif projection_type == 'name-only': projection = UserProjection.IdNameImage() pageSize = TwitterCachePage.PAGE_SIZE_ID_NAME_DATA else: return redirect_problem('Unsupported projection type: %s' % projection_type) if followee is None: return redirect_problem('Followee is required') users = readUsersFromCache(None, instance, cache_id, start_epoch, end_epoch, page_num, pageSize, followee, userProjection=projection) if users is not None: for user in users: assert isinstance(user, User) data.append([user.id, user.name, user.profile_image_url, UserInformationPage.link_info.getPageLink(instance, user.id)]) return {'json' : data}
def func(templateArguments): placeName = parseString(request.GET.place_name) data = list() if placeName is None: return {'json': data} locations = list() maxLocations = 10 locations += GeocodeResultAbstract.searchGnsByName(placeName, 3) maxLocations -= len(locations) if maxLocations > 0: newLocations = geocodeSearch(self.provider_id, placeName, maxLocations) maxLocations -= len(newLocations) locations += newLocations for location in locations: assert isinstance(location, GeocodeResultAbstract) data.append((location.cache_id, location.bounding_box, location.coordinate, location.display_name)) return {'json': data}
def func(templateArguments): placeName = parseString(request.GET.place_name) data = list() if placeName is None: return {'json' : data} locations = list() maxLocations = 10 locations += GeocodeResultAbstract.searchGnsByName(placeName,3) maxLocations -= len(locations) if maxLocations > 0: newLocations = geocodeSearch(self.provider_id,placeName,maxLocations) maxLocations -= len(newLocations) locations += newLocations for location in locations: assert isinstance(location,GeocodeResultAbstract) data.append((location.cache_id,location.bounding_box,location.coordinate,location.display_name)) return {'json' : data}
def start_instance_get(self, template_arguments): template_arguments.update({"post_address": StartInstancePost.link_info.getPageLink()}) keywords = request.GET.keywords regions = parseString(request.GET.regions, default="{}") instanceSetupCode = parseString(request.GET.instance_setup_code, default="") template_arguments.update( { "home_link": getHomeLink(Configuration.PROJECT_NAME), "keywords": keywords, "regions": regions, "instance_setup_code": instanceSetupCode, "max_geographical_filters": Configuration.TWITTER_MAX_GEO_FILTERS, } ) error = request.GET.error if len(error) > 0: template_arguments.update({"error": error}) return template("instance-start.tpl", template_arguments)
def func(templateArguments, instance): dataType = parseString(request.GET.type, ['tweet', 'user']) start_epoch = parseInteger(request.GET.start_epoch) end_epoch = parseInteger(request.GET.end_epoch) page_num = parseInteger(request.GET.page) place_id = parseInteger(request.GET.place_id) provider_id = parseInteger(request.GET.provider_id) projection_type = parseString(request.GET.projection_type) followee = parseInteger(request.GET.followee) cache_id = GeocodeResultAbstract.buildCacheId( provider_id, place_id) if dataType is None: return redirect_problem('type is a required argument') if page_num is None: page_num = 0 data = [] if dataType == 'tweet': tweets = readTweetsFromCache( None, instance, cache_id, start_epoch, end_epoch, page_num, TwitterCachePage.PAGE_SIZE_FULL_DATA) if tweets is not None: for tweet in tweets: assert isinstance(tweet, Tweet) userHtml = UserInformationPage.getPageLinkImage( instance, tweet.user, target='_self') data.append([ tweet.created_at, userHtml, tweet.user.location_text, tweet.text ]) elif dataType == 'user': if len(projection_type) == 0: projection = None pageSize = TwitterCachePage.PAGE_SIZE_FULL_DATA elif projection_type == 'name-only': projection = UserProjection.IdNameImage() pageSize = TwitterCachePage.PAGE_SIZE_ID_NAME_DATA else: return redirect_problem('Unsupported projection type: %s' % projection_type) if followee is None: return redirect_problem('Followee is required') users = readUsersFromCache(None, instance, cache_id, start_epoch, end_epoch, page_num, pageSize, followee, userProjection=projection) if users is not None: for user in users: assert isinstance(user, User) data.append([ user.id, user.name, user.profile_image_url, UserInformationPage.link_info.getPageLink( instance, user.id) ]) return {'json': data}