Tim Chase | 24 Oct 15:51 2014
Picon

http://web2py.com/layouts

I couldn't find anyplace other than this group at http://web2py.com to report this.

At http://web2py.com/layouts, Under About --> About plugins, the link is http://web2py.com/book/default/chapter/13#Plugins. I think that the "13" should probably be a "12".

--Tim

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Dave S | 24 Oct 21:14 2014
Picon

custom ordering on queries

This is a more general DB query, but I've learned to trust the web2py community, and web2py is where the answer will do me the most good.

I'm looking at a table where I want to have a custom ordering on a field.  Standard ascending and descending don't quite work for me in the use I'm interested in.  What I want to do is sort the field ("owner") so that the value I'm most interested in is at the top ("owner='dave'"), and the rest of the entries are sorted asc or desc.  Is there a way to do that in a single query, or do I need to make 2 queries and concatenate the results?  Is "group by" an appropriate SQL clause here?

Also, would that solution generalize to sorting by a set of values of interest at the top ("owner='dave'|'bob'|'andy'")?

Thanks.

/dps

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Rod Watkins | 24 Oct 19:29 2014
Picon

Rocket use

Hello all,

I am about ready to start deploying my site. It is a private site for about 8-10 users. I was wondering if, given the small size, whether it would be safe to use the rocket web server, rather than apache or nginx?

Thanks
Rod

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Nurendra Choudhary | 24 Oct 09:13 2014
Picon

IS_EMPTY_OR not working for file upload

I gave this validator.
requires=(IS_EMPTY_OR(IS_UPLOAD_FILENAME(extension='pdf')))

But when I submit the form I still get the error Enter a valid file name.
Please help me.


--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
tahnoon pasha | 24 Oct 10:33 2014
Picon

Getting web2py to reload module files for each return view

Hi,

Working with a team building a reasonably complex webapp  for an investment management system, and  I'm trying to learn something of the system too.

I have a module that updates data from a file (simulating an FTP drop). Once the module has been loaded the first time, it doesn't update for either changes in code or in the underlying data no matter how often I refresh the page. 

Is there a particular way to force web2py to reload any files each time a page is refreshed? Am I doing something completely wrong?

Thanks

The code is as follows:

module: dataxl.py

from gluon import *
import csv
import json
import os
from xlrd import open_workbook as lox




def mydata():
    filepath
= os.join(current.request.folder, 'static', 'sample-data', \
                       
'20-10-2014_sample-data-for-designer.xls')
    oldbook
= lox(filepath)
    names
= oldbook.sheet_names()
    workbook
= {}
   
for name in names:
        worksheet
= []
        oldsheet
= ws.sheet_by_name(name)
        nrows
= oldsheet.nrows
        ncols
= oldsheet.ncols
        colnames
= [ oldsheet.cell(0,i).value for i in range(ncols) ]
        rownames
= [ oldsheet.cell(i,0).value for i in range(nrows) ]
       
for nrow in xrange(1,nrows):
            worksheet
.append({colnames[ncol]: oldsheet.cell(nrow,ncol).value \
                             
for ncol in xrange(ncols)})
        workbook
[name] = worksheet
   
return workbook

controller: performance.py

import dataxl


wsheet
= dataxl.mydata()

attr
= wsheet[ 'Performance_Attr' ]

<at> auth.requires_login()
def perf_multi_asset():

    clientId
= set(i[ 'client' ] for i in attr.values())
    portId
= [ 'All' ]
    portId
.append(j for j in set(i[0] for i in attr.items() \
                                 
if i[ 1 ][ 'Attribution Level' ] == 0 \
                                 
or i[ 1 ][ 'Attribution Level' ] == 1))

    perform
= SQLFORM.factory(
       
Field('client', 'string'),requires=IS_IN_SET(clientId)),
       
Field('portfolio', 'string'),requires=IS_IN_SET(portId)),
       
Field('start_date', 'date'),
       
Field('end_date', 'date')
   
).process()

   
if perform.vars.portfolio == 'All':
        data
= {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client}
   
else:
        data
= {i[ 0 ]:i[ 1 ] for i in attr.items() if i[ 1 ][ 'client' ] == perform.vars.client \
               
and i[ 0 ] == perform.vars.portfolio}

   
return locals()

and view: performance/perf_multi_asset.html

{{left_sidebar_enabled,right_sidebar_enabled=False,('message' in globals())}}
{{extend 'layout.html'}}

{{=STYLE(XML(".generic-widget,#no_table_start_date,#no_table_end_date {width:100px}"))}}

<div class="row">
    {{=perform.custom.begin}}

    <div class="span2">
        Client Name: <br>
        {{=perform.custom.widget.client}}
    </div>

    <div class="span2">
        Portfolio ID: <br>
        {{=perform.custom.widget.portfolio}}
    </div>

    <div class="span2">
        Start Date: <br>
        {{=perform.custom.widget.start_date}}
    </div>

    <div class="span2">
        End Date: <br>
        {{=perform.custom.widget.end_date}}
    </div>

    <div class="span2">
        <br>
        {{=perform.custom.submit}}
    </div>

    {{=perform.custom.end}}
    
</div>

{{=BEAUTIFY(XML(data))}}

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Dexter Hadley | 23 Oct 20:23 2014
Picon

Exporting from a SQLFORM.grid with customized search queries

Hi All,

This is my first time posting a question, so thanks to Massimo and they whole community for making web2py.  Its great!

I am trying to export results from a customized full-text search using SQLFORM.grid.  My backend is a Postgres db, and I successfully define "search_widget" and "searchable" functions that are passed to the SQLFORM.grid to do the full-text search.  It will works pretty well on the web app.  However, once I click the export button, SQLFORM.grid apparently recreates the query using the default SQLFORM.build_query and ignores the correct query which I define in searchable.  After poking around in sqlhtml.py, I found this is so because the exporter only conditions on request.vars.keywords before calling  SQLFORM.build_query, and it does not check for callable(searchable) which I think it should do.  In fact, I fixed it by editing sqlhtml.py to force the exporter to condition on (request.vars.keywords and callable(searchable)) before setting up the rows object to export.  The code I added is in bold below (on line 2298 of sqlhtml.py):

                if request.vars.keywords and callable(searchable):
                    try:
                        #the query should be constructed using searchable fields but not virtual fields
                        sfields = reduce(lambda a, b: a + b,
                            [[f for f in t if f.readable and not isinstance(f, Field.Virtual)] for t in tables])
                        dbset = dbset(SQLFORM.build_query(
                            sfields, request.vars.get('keywords', '')))
                        rows = dbset.select(left=left, orderby=orderby,
                                            cacheable=True, *selectable_columns)
                    except Exception, e:
                        response.flash = T('Internal Error')
                        rows = []
                else:
                    rows = dbset.select(left=left, orderby=orderby,
                                        cacheable=True, *selectable_columns)

Is this a bug or is there a better way to do an export of customized search results using SQLFORM.grid?  I'm using the current version of everything (web2py 2.9.11, Postgres 9.3, Python 2.7.8).  Thx again,

dex*

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Gianganh Nguyen | 24 Oct 12:36 2014
Picon

Question about a field boolean in MSSQL


Hello to everybody,
I have a question, please answer for me!

In the model, I define a field:
db.define_table('mytable',
                          Field('is_imported', 'boolean', default = False), ...)
db.mytable.insert(is_imported = True,..)
db.mytable.insert(is_imported = False,..)

In the controller, I write:
records = db(db.mytable.id).select(db.mytable.is_imported)
for record in records:
    print record.is_imported

Result:
     False
     False

Expected result:
    True
     False

And I see with boolean fields, command select always return False for every values (0, 1) in mssql.
I were trying with all mssql and mssql2, they had same result.

Please tell me why.
Thanks.

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Louis Amon | 24 Oct 11:41 2014
Picon

Sticky sessions in a distributed environment

I am trying to scale up my application deployed on Heroku by increasing the number of dynos and am currently confronted with the issue of handling sessions in a distributed environment.

The regular solution (storing sessions in the database) does not seem to work anymore when multiple dynos run concurrently : clients get asked for login at every request.
I have no idea why this doesn't work since databases are supposed to be shared between dynos on Heroku, but as far as I know there are 2 possible ways to manage scalable sticky sessions:

  1. Memcache : couldn't use gluon/contrib to test this because the MemcacheClient does not allow authentication in a connection string (i.e. services like Memcached, MemCachier...)
  2. Redis : same issue --> Redis client does not seem to work well with auth-based services that are available on Heroku (e.g. RedisCloud)


Any idea why db-based sessions do not stick out of the box on Heroku, and/or how to use a Cloud-based service to achieve session stickiness ?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
LoveWeb2py | 24 Oct 03:18 2014
Picon

best way to play sound one time? session or cookies

Hello,

I would like to greet or user with a sound one time upon accessing a controller but if they click it again i
would want the sound to play again while they're logged in.  However if they log out and log back in I would
like it to play again.  What type of logic should I use sessions or cookies?  What is av better fit. 

--

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe@...
For more options, visit https://groups.google.com/d/optout.

Ruud Schroen | 23 Oct 16:17 2014
Picon

Removing password_two comment

Hi guys,

I'm using a auth_register() form. Right now, the password_two field (the one that requires you to re-enter your password) shows a comment next to it saying " you need to re-enter your password"  or something.
Now I want to remove that comment using the following:

db.auth_user.password_two.comment = None

or

db.auth_user.password_two.comment = ''"

However, I get the following error:

AttributeError: 'Table' object has no attribute 'password_two'

What should I do?

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.
Carl Petersen | 23 Oct 15:07 2014
Picon

reference auth_user from a table in one database to the auth_user table in another database

Hello,

I'm trying to reference the auth_user table in one database from a field definition for a table in a different database.  Hopefully the code below will clarify:

db1 = DAL('postgres://user:password <at> host1/database1',pool_size=1,check_reserved=None,migrate=False)
db = DAL('postgres://user:password <at> host/database',pool_size=1,check_reserved=['all'],migrate=False)

db1.executesql("set search_path to 'devxref','public';")
db.executesql("set search_path to 'po','xref','dw','public';")

db.define_table('x_vendor',
    Field('source_vendor_dwid',db.d_supplier_source),
    Field('source_vendor_id'),
    Field('source_system_dwid',db.d_source),
    Field('source_system_id'),
    Field('gp_vendor_dwid',db.d_supplier_source),
    Field('gp_vendor_id'),
    Field('changed_date_time','datetime',
          default=request.now, update=request.now, writable=False),
    Field('changed_user_id','reference db1.auth_user',
          default=auth.user_id, update=auth.user_id, writable=False),
    format='%(x_vendor)s')

I get the following errors in the dump:

Traceback (most recent call last):
File "/opt/web-apps/web2py/gluon/restricted.py", line 224, in restricted
exec ccode in environment
File "/opt/web-apps/web2py/applications/wspg/controllers/x_vendor.py", line 127, in <module>
File "/opt/web-apps/web2py/gluon/globals.py", line 392, in <lambda>
self._caller = lambda f: f()
File "/opt/web-apps/web2py/applications/wspg/controllers/x_vendor.py", line 85, in add
if form.process().accepted:
File "/opt/web-apps/web2py/gluon/html.py", line 2303, in process
self.validate(**kwargs)
File "/opt/web-apps/web2py/gluon/html.py", line 2240, in validate
if self.accepts(**kwargs):
File "/opt/web-apps/web2py/gluon/sqlhtml.py", line 1671, in accepts
self.vars.id = self.table.insert(**fields)
File "/opt/web-apps/web2py/gluon/dal.py", line 9320, in insert
ret = self._db._adapter.insert(self, self._listify(fields))
File "/opt/web-apps/web2py/gluon/dal.py", line 1354, in insert
query = self._insert(table, fields)
File "/opt/web-apps/web2py/gluon/dal.py", line 2903, in _insert
values = ','.join(self.expand(v, f.type) for f, v in fields)
File "/opt/web-apps/web2py/gluon/dal.py", line 2903, in <genexpr>
values = ','.join(self.expand(v, f.type) for f, v in fields)
File "/opt/web-apps/web2py/gluon/dal.py", line 1555, in expand
return str(self.represent(expression, field_type))
File "/opt/web-apps/web2py/gluon/dal.py", line 3079, in represent
return BaseAdapter.represent(self, obj, fieldtype)
File "/opt/web-apps/web2py/gluon/dal.py", line 2016, in represent
ftype = self.db[p[0]][p[2]].type
File "/opt/web-apps/web2py/gluon/dal.py", line 8512, in __getitem__
return self.__getattr__(str(key))
File "/opt/web-apps/web2py/gluon/dal.py", line 8522, in __getattr__
return ogetattr(self, key)
AttributeError: 'DAL' object has no attribute 'db1'


Any assistance would be greatly appreciated.

Thanks!

Carl

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Gmane