patch to apply to trunk. Please test it extensively with all the possible 
combinations.

On Wednesday, November 7, 2012 2:23:35 PM UTC+1, Niphlod wrote:
>
> at that point you miss formatting fields and references. In addition, 
> db.executesql() doesn't return an iterator either. You should code your own 
> exporter using db._adapter.execute() and a yielding fetchone()s.
>
> On Wednesday, November 7, 2012 2:01:45 PM UTC+1, Johann Spies wrote:
>>
>> On 7 November 2012 14:05, Niphlod <nip...@gmail.com> wrote:
>>
>>> if your set doesn't fit into memory, saving it to a temp file won't get 
>>> you out of troubles. One of DAL problems is that a Rows object does not 
>>> return an iterator from the cursor, it's fetched all into memory first.
>>>
>>>
>> In that case I would be inclined to use bypass DAL and db.executesql and 
>> use the backend to export to a file.  That should be more efficient.
>>
>> Regards
>> Johann
>> -- 
>> Because experiencing your loyal love is better than life itself, 
>> my lips will praise you.  (Psalm 63:3)
>>
>>

-- 



@@ -1934,25 +1934,23 @@ class SQLFORM(FORM):
                     orderby = db[tablename][fieldname]
                     if sign == '~':
                         orderby = ~orderby
-
-            table_fields = [f for f in fields if f._tablename in tablenames]
-            if (export_type in ('csv_with_hidden_cols', 'tsv_with_hidden_cols')
-                    and export_type in exportManager):
+            expcolumns = columns
+            if export_type.endswith('with_hidden_cols'):
+                expcolumns = [f for f in fields if f._tablename in tablenames]
+            if export_type in exportManager:
                 if request.vars.keywords:
                     try:
                         dbset = dbset(SQLFORM.build_query(
                             fields, request.vars.get('keywords', '')))
-                        rows = dbset.select(cacheable=True)
+                        rows = dbset.select(cacheable=True, *expcolumns)
                     except Exception, e:
                         response.flash = T('Internal Error')
                         rows = []
                 else:
-                    rows = dbset.select(cacheable=True)
-            else:
-                rows = dbset.select(left=left, orderby=orderby,
-                                    cacheable=True, *columns)
+                    rows = dbset.select(left=left, orderby=orderby,
+                                    cacheable=True, *expcolumns)
 
-            if export_type in exportManager:
+                #begin building up exported file
                 value = exportManager[export_type]
                 clazz = value[0] if hasattr(value, '__getitem__') else value
                 oExp = clazz(rows)

Reply via email to