Specialization of DataAccess.page that returns models instead of cursor objects.
508666
def page_models(self, constructor, paging, constraints=None, *, columns=None, order_by=None):
    """"""
    records, count = self.page(constructor.table_name, paging, constraints, columns=columns,
                               order_by=order_by)
    return ([constructor(r) for r in records], count)
980607
def query_model(self, model, condition=None, offset=None, limit=None,
                    group_by=None, having=None, order_by=None, fields=None):
        
        if self._query is not None:
            query = self._query
        else:
            query = self.get_select()
            
        if condition is not None:
            if isinstance(query, Result):
                query = query.filter(condition)
            else:
                query = query.where(condition)
        if self.pagination:
            if offset is not None:
                query = query.offset(int(offset))
            if limit is not None:
                query = query.limit(int(limit))
        if order_by is not None:
            if isinstance(order_by, (tuple, list)):
                for order in order_by:
                    query = query.order_by(order)
            else:
                query = query.order_by(order_by)
        if group_by is not None:
            if isinstance(group_by, (tuple, list)):
                query = query.group_by(*group_by)
            else:
                query = query.group_by(group_by)
            if having is not None:
                query = query.having(having)
        return query
467142
def _expose_models(cls):
        
        if db._IS_OK_:
            register_models(**{m.__name__: m
                               for m in db.Model.__subclasses__()
                               if not hasattr(models, m.__name__)})
1357573
def get_models(self, columns=None):
        
        results = self.apply_scopes().get_query().get(columns).all()

        connection = self._model.get_connection_name()

        models = self._model.hydrate(results, connection)

        return models
423772
def lookup_object(model, object_id, slug, slug_field):
    
    lookup_kwargs = {}
    if object_id:
        lookup_kwargs['%s__exact' % model._meta.pk.name] = object_id
    elif slug and slug_field:
        lookup_kwargs['%s__exact' % slug_field] = slug
    else:
        raise GenericViewError(
            "Generic view must be called with either an object_id or a"
            " slug/slug_field.")
    try:
        return model.objects.get(**lookup_kwargs)
    except ObjectDoesNotExist:
        raise Http404("No %s found for %s"
                      % (model._meta.verbose_name, lookup_kwargs))
668475
def select(cls, *args, **kwargs):
        """"""
        query = super(Model, cls).select(*args, **kwargs)
        query.database = cls._get_read_database()
        return query
368948
function getInitialModel(routeInfo, page) {
    var initModelDeps = {
        appName:    routeInfo.appName,
        tokens:     routeInfo.tokens,
        routeInfo:  routeInfo,
        defaults:   page.defaults,
        activeUser: routeInfo.activeUser || {},
        currentScope: {}
    };

    // if no model, just return empty object
    if (!page.model) {
        return Q.when({});
    }
    // if function, inject and the returned value is the model
    else if (_.isFunction(page.model)) {
        return Q.when(injector.loadModule(page.model, null, { dependencies: initModelDeps }));
    }
    else {
        throw new Error(routeInfo.name + ' page invalid model() format: ' + page.model);
    }
}
358489
function lookup( pageRef ) {
      const page = deepClone( artifactsByRef.pages[ pageRef ] );
      removeDisabledItems( page );
      return page;
   }
182199
def for_model(self, model, **kwargs):
        
        queryset = self.filter(
            content_types=ContentType.objects.get_for_model(model),
            **kwargs
        )
        return queryset
1096879
def listDatasetAccessTypes(self, dataset_access_type=""):
        
        if isinstance(dataset_access_type, basestring):
            try:
                dataset_access_type = str(dataset_access_type)
            except:    
                dbsExceptionHandler('dbsException-invalid-input', 'dataset_access_type given is not valid : %s' %dataset_access_type)
        else:
            dbsExceptionHandler('dbsException-invalid-input', 'dataset_access_type given is not valid : %s' %dataset_access_type)
        conn = self.dbi.connection()
        try:
            plist = self.datasetAccessType.execute(conn, dataset_access_type.upper())
            result = [{}]
            if plist:
                t = []
                for i in plist:
                    for k, v in i.iteritems():
                        t.append(v)
                result[0]['dataset_access_type'] = t
            return result
        finally:
            if conn:
                conn.close()
1152712
def GetConvertersByClass(value_cls):
    """"""
    try:
      return ExportConverter.converters_cache[value_cls]
    except KeyError:
      results = [
          cls for cls in itervalues(ExportConverter.classes)
          if cls.input_rdf_type == value_cls
      ]
      if not results:
        results = [DataAgnosticExportConverter]

      ExportConverter.converters_cache[value_cls] = results
      return results
1149687
def get_queryset(self):
        '''
        
        '''
        request = self.request

        # Allow pages to be filtered to a specific type
        if 'type' not in request.GET:
            model = Page
        else:
            model_name = request.GET['type']
            try:
                model = resolve_model_string(model_name)
            except LookupError:
                raise BadRequestError("type doesn't exist")
            if not issubclass(model, Page):
                raise BadRequestError("type doesn't exist")

        # This is the overwritten line
        queryset = model.objects.public()  # exclude .live()

        # Filter by site
        queryset = queryset.descendant_of(
            request.site.root_page, inclusive=True)

        return queryset
918632
private static DataSet<Long> getPagesDataSet(ExecutionEnvironment env, ParameterTool params) {
		if (params.has("pages")) {
			return env.readCsvFile(params.get("pages"))
				.fieldDelimiter(" ")
				.lineDelimiter("\n")
				.types(Long.class)
				.map(new MapFunction<Tuple1<Long>, Long>() {
					@Override
					public Long map(Tuple1<Long> v) {
						return v.f0;
					}
				});
		} else {
			System.out.println("Executing PageRank example with default pages data set.");
			System.out.println("Use --pages to specify file input.");
			return PageRankData.getDefaultPagesDataSet(env);
		}
	}
365627
private Map getInfoList4PageServiceInnerEx(Map requestParamMap0,String tableName,Map pageMap,String cusWhere,String cusSelect,String modelName,List cusPlaceList) throws Exception{
		//add 201807 ning
		//Map requestParamMap=changeCase4Param(requestParamMap0);
		//add 201902 ning
		Map requestParamMap=new CaseInsensitiveKeyMap();
		if(requestParamMap0!=null){
			requestParamMap.putAll(requestParamMap0);
		}
		String page=(String) pageMap.get("page");
		String rows=(String) pageMap.get("rows");
		String sort=(String) pageMap.get("sort");
		String order=(String) pageMap.get("order");
		String cusSort=(String) pageMap.get("cusSort");
		
		String tempDbType=calcuDbType();
		
		Integer pageNum=Integer.valueOf(page);
		Integer rowsNum=Integer.valueOf(rows);
		
		if(modelName==null || "".equals(modelName)){
			modelName=tableName;
		}
		
		String tempKeyId=calcuIdKey();
		String id=(String) requestParamMap.get(tempKeyId);
		String where="";

		if(cusWhere !=null && !"".equals(cusWhere)){
			where="where "+cusWhere;
		}
		
		String whereCols="";	
		
		Map whereColsMap=requestParamMap;
		if(whereColsMap!=null && !whereColsMap.isEmpty()){
			StringBuilder sb=new StringBuilder("");
			Set<String> keySet=whereColsMap.keySet();
			int i=0;
			for(String key:keySet){
				if(!key.contains(".")){
					continue;
				}
				if(key.contains("dbcol_")){
					continue;
				}				
				String colName=key;
				String realColName=colName.replace(".", CheckModelTypeUtil.DUMMY_SPLIT);
				String colsStr=colName+" as "+realColName;
				if(i==0){
					sb.append(colsStr);	
				}else{
					sb.append(",").append(colsStr);
				}
				i++;
			}
			whereCols=sb.toString();
		}
		
		Map modelEntryMap=getModelEntryMap(requestParamMap,tableName,modelName,dbName,whereCols);
		List placeList=new ArrayList();
		String whereInStr=createWhereInStr(requestParamMap,modelEntryMap,placeList);
		if(whereInStr!=null && !"".equals(whereInStr)){
			if(!where.equals("")){
				where=where+" and "+whereInStr;
			}else{
				where="where "+whereInStr;
			}
		}
		List realPlaceList=new ArrayList();
		//realPlaceList.addAll(placeList);
		if(cusPlaceList==null){
			cusPlaceList=new ArrayList();
		}
		realPlaceList.addAll(cusPlaceList);
		
		//add 20170927
		realPlaceList.addAll(placeList);
		String selectCount="select count(1) from "+tableName+" "+where;
		Integer total=getInnerDao().queryObjJoinCountByCondition(selectCount,realPlaceList.toArray());
		String select="";
		if(cusSelect!=null && !"".equals(cusSelect)){
			select="select "+cusSelect+" from "+tableName+" "+where; 
		}else{
			select="select * from "+tableName+" "+where;
		}

		String orderSql="";
		if(cusSort!=null && !"".equals(cusSort)){
			orderSql="order by "+cusSort;
		}else if(sort!=null && !sort.equals("")){
			orderSql="order by "+sort+" "+order;
		}

		String sql=select+" "+orderSql;
		int startNum=getInnerDao().calcuStartIndex(pageNum-1, rowsNum);
		int endNum=startNum+rowsNum;

		List infoList=getInnerDao().queryObjJoinDataByPageCondition(sql, startNum, endNum,realPlaceList.toArray());
		if(infoList==null){
			infoList=new ArrayList();
		}
		CheckModelTypeUtil.addMetaCols(infoList);

		CheckModelTypeUtil.changeNoStrCols(infoList);
		Map retMap=new HashMap();
		retMap.put("rows", infoList);
		retMap.put("total", total);
		return retMap;
	}
735446
def get_document_models():
    """"""
    mappings = {}
    for i in get_index_names():
        for m in get_index_models(i):
            key = "%s.%s" % (i, m._meta.model_name)
            mappings[key] = m
    return mappings
589675
function(methodMapper, request, response, callback) {
      var modelMethod = methodMapper[request.method];
      if (access[modelMethod] === true) {
        return callback(null, true);
      }

      return application.access(request, access[modelMethod], callback);
    }
785329
private static AccessInfo getAccessInfo
        (StorableProperty property,
         int dataType, String dataTypeName, int columnSize, int decimalDigits)
    {
        AccessInfo info = getAccessInfo
            (property.getType(), dataType, dataTypeName, columnSize, decimalDigits);
        if (info != null) {
            return info;
        }

        // Dynamically typed data sources (e.g. SQLite3) always report 
        // dataType as java.sql.Types.VARCHAR.  Infer the dataType from the 
        // dataTypeName and try again.
        if (dataType == java.sql.Types.VARCHAR) {
            Integer dataTypeMapping = typeNameToDataTypeMapping.get(dataTypeName.toUpperCase());
            if (dataTypeMapping != null) {
                info = getAccessInfo
                    (property.getType(), dataTypeMapping, dataTypeName, columnSize, decimalDigits);
                if (info != null) {
                    return info;
                }
            }     
        }

        // See if an appropriate adapter exists.
        StorablePropertyAdapter adapter = property.getAdapter();
        if (adapter != null) {
            Method[] toMethods = adapter.findAdaptMethodsTo(property.getType());
            for (Method toMethod : toMethods) {
                Class fromType = toMethod.getParameterTypes()[0];
                // Verify that reverse adapt method exists as well...
                if (adapter.findAdaptMethod(property.getType(), fromType) != null) {
                    // ...and try to get access info for fromType.
                    info = getAccessInfo
                        (fromType, dataType, dataTypeName, columnSize, decimalDigits);
                    if (info != null) {
                        info.setAdapter(adapter);
                        return info;
                    }
                }
            }
        }

        return null;
    }