Re: [web2py] Passenger WSGI Session

2013-02-11 Thread Vaibhav Kapoor
Thank you for your response but I finally figured out the problem.

To make RPC calls it seems that user needs to be authenticated on 
Dreamhost, so when I login with my app:

 user:pass@*www.*app.dreamhost.com/app/default/call/jsonrpc


 Another important thing to remember is that without the www. none of the 
calls seem to work, or some forwarding is going with dreamhost(not sure if 
its a bug of a config problem).

Now one of the other reasons I was having session issues is because the 
simplejsonrpc doesn't actually keep track of the session cookie. 

Thankfully the android-json-rpc http://code.google.com/p/android-json-rpc/ 
has 
session transport capabilities.

I managed to get session by manually sending the HTTP headers and payload 
with the session cookie. 
But I would really like to have session capabilities, as my (client) 
programs are going to need them. I have been scavenging all around but have 
not been able to find a library that supports it.

I was going to give programming it a shot, but I kinda would like some 
direction on how I should implement it. Also I haven't used Mixins before 
so I am going to have to play with those.

Thanks.

On Monday, January 28, 2013 2:39:46 PM UTC-5, Roberto De Ioris wrote:


  Unfortunately according to web2py on 
  Dreamhosthttp://wiki.dreamhost.com/Web2py, 
  only FastCGI and Passenger WSGI seem to work. And that Passenger works 
  significantly faster than FastCGI. I had heard the stability of 
 Passenger 
  WSGI was also better on Dreamhost. But I can give FastCGI a chance, but 
 is 
  there an Apache file to configure then(to the access.wsgi) for sessions 
  with service calls? 
  
  I have voted for Dreamhost to setup mod_wsgi, but who knows when that 
 will 
  happen. 
  
  Thank you. 
  Kitu. 

 I am pretty sure i can make uWSGI to work pretty easily on dreamhost (via 
 fastcgi). Would you mind asking them if they want to contact me privately 
 to make some test ? 


 -- 
 Roberto De Ioris 
 http://unbit.it 


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] serial no. in SQLFORM.grid

2013-02-11 Thread Pankaj Pathak
Good noon to all,

Is there any technic to set serial no in SQLGRID, i have try following code 
for it but i am not satisfied,
db.define_table(material, 
Field(serial_no, writable=False,),
Field(material_type, requires=IS_IN_SET(['Capax', 
'Opax']), default = Capax),
Field(code),
Field(description),
Field(unit),
Field(price),
) 
material_table_ids = [i.id for i in db(db.material).select()]   
 
db.material.serial_no.represent = lambda id,row: 
material_table_ids.index(row and row.id or material_table_ids[-1])+1   
  

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How can do muliple check boxes if a group and only allow the user the select 1.

2013-02-11 Thread Dan Kozlowski


On Sunday, February 10, 2013 5:07:16 PM UTC-6, Dan Kozlowski wrote:

 How can do muliple check boxes if a group and only allow the user the 
 select 1. I  used the smart grid to create the add and update.


 Dog or Cat and only 1 can be selected.  



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Star Rating

2013-02-11 Thread Alan Etkin


 Here is the code that worked for me when added to the view. ...


Good catch, I should have added the .ready call to wait until the form 
element is available.

The rating plugin worked without this. We could fix the plugin script so 
there's no need for the workaround. 
 

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: serial no. in SQLFORM.grid

2013-02-11 Thread Niphlod
uhm  that code will put down your db as soon as material gets a few 
lines  a better way is to fetch the latest id using orderby and limit

new_id = db(db.material.id0).select(db.material.id, 
orderby=~db.material.id, limitby=(0,1)).first()
new_id = new_id and new_id + 1 or 1

But.if you need a serial_no that basically is equal to the id of that 
table, you have two better (at least for my point of view) options

db.define_table('material',
 .
 .
   Field(serial_no, id)
)

or just use the id and name the column in the grid as serial_no passing 
the colnames in the headers parameters of the grid

headers = {'material.id' : Serial No}

On Monday, February 11, 2013 10:09:12 AM UTC+1, Pankaj Pathak wrote:

 Good noon to all,

 Is there any technic to set serial no in SQLGRID, i have try following 
 code for it but i am not satisfied,
 db.define_table(material, 
 Field(serial_no, writable=False,),
 Field(material_type, requires=IS_IN_SET(['Capax', 
 'Opax']), default = Capax),
 Field(code),
 Field(description),
 Field(unit),
 Field(price),
 ) 
 material_table_ids = [i.id for i in db(db.material).select()] 

 db.material.serial_no.represent = lambda id,row: 
 material_table_ids.index(row and row.id or material_table_ids[-1])+1 
 


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: @auth.requires_membership('Admin') and @auth.requires(auth.has_membership(role = 'Admin'))

2013-02-11 Thread 黄祥
another strange behaviour is when @auth.requires(auth.has_membership(role = 
'Admin')) put on the function that call it, the add function didn't work

*work*
*@auth.requires(auth.has_membership(role = 'Admin')) ## here is the 
difference*
def __grid_0(flash, table):
response.flash=T(flash)
has_membership=auth.has_membership('Admin')
grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
   create=has_membership,
   editable=has_membership,
   deletable=has_membership)
return dict(grid=grid)

def manage_blog():
return __grid_0(blog_manage_flash, blog_db)

*not work*
def __grid_0(flash, table):
response.flash=T(flash)
has_membership=auth.has_membership('Admin')
grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
   create=has_membership,
   editable=has_membership,
   deletable=has_membership)
return dict(grid=grid)

*@auth.requires(auth.has_membership(role = 'Admin'))** ## here is the 
difference*
def manage_blog():
return __grid_0(blog_manage_flash, blog_db)

did anyone know why it like that?

thank you so much in advance

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] clear data session

2013-02-11 Thread 黄祥
hai,

is there a way to clear data session?
i've tried session.clear() it seems not work
any help is greatly appreciate.

many thanks in advance

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server konfigurations basics redirects

2013-02-11 Thread BlueShadow
OK the routes.py option sounds pretty promissing. still I will have a 
problem when I start my second app. So what do I do if I got two 
domainnames?

And I would like to hide the application name if it is possible.

So www.dname1.com= ip/App1/
and www.dname2.com= ip/App2/


On Monday, February 11, 2013 8:07:01 AM UTC+1, Emilius Omeen wrote:


 rename your application to init or edit /web2py/routes.py 

 default_application = 'your application name'# ordinarily set in base 
 routes.py
 default_controller = 'default'  # ordinarily set in app-specific routes.py
 default_function = 'index'  # ordinarily set in app-specific routes.py



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: clear data session

2013-02-11 Thread Anthony
session.clear() should work. Can you show more code and explain the exact 
behavior you are seeing?

On Monday, February 11, 2013 8:30:49 AM UTC-5, 黄祥 wrote:

 hai,

 is there a way to clear data session?
 i've tried session.clear() it seems not work
 any help is greatly appreciate.

 many thanks in advance


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Error in admin application when sessions expired or deploying new application

2013-02-11 Thread Mickael Corniere
Hello,

I have a strange error on admin error. Even with no customized application 
deployed, sometimes admin application crashes  with this message on web 
page:

Internal errorTicket issued: 
unrecoverablehttps://intranet-t4dm.si.francetelecom.fr/admin/default/ticket/unrecoverable

And in the log I get :
2013-02-11 14:33:02,293 - web2py - ERROR - Traceback (most recent call 
last):
  File /opt/application/web2py/current/web2py/gluon/main.py, line 576, in 
wsgibase
session._try_store_in_cookie_or_file(request, response)
  File /opt/application/web2py/current/web2py/gluon/globals.py, line 749, 
in _try_store_in_cookie_or_file
self._try_store_in_file(request, response)
  File /opt/application/web2py/current/web2py/gluon/globals.py, line 755, 
in _try_store_in_file
if not response.session_id or self._forget or self._unchanged():
  File /opt/application/web2py/current/web2py/gluon/globals.py, line 711, 
in _unchanged
session_pickled = cPickle.dumps(dict(self))
  File /usr/lib64/python2.6/copy_reg.py, line 70, in _reduce_ex
raise TypeError, can't pickle %s objects % base.__name__
TypeError: can't pickle function objects

My version of web2py is 2.3.2

I manage sometimes to deploy application by removing sessions file, bu 
today impossible to make it works :'(

Thx


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Error in admin application when sessions expired or deploying new application

2013-02-11 Thread Alan Etkin
 I manage sometimes to deploy application by removing sessions file, bu 
today impossible to make it works :'(

Are you assigning to session a function/lambda?

session.f = lambda x: x+1 # this is not legal

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Error in admin application when sessions expired or deploying new application

2013-02-11 Thread Mickael Corniere
Hello Allan,

The answer is no. As the application is the appadmin, I didn't change it. I 
use the one given by web2py.

Thx

Le lundi 11 février 2013 15:28:14 UTC+1, Alan Etkin a écrit :

  I manage sometimes to deploy application by removing sessions file, bu 
 today impossible to make it works :'(

 Are you assigning to session a function/lambda?

 session.f = lambda x: x+1 # this is not legal


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: @auth.requires_membership('Admin') and @auth.requires(auth.has_membership(role = 'Admin'))

2013-02-11 Thread Anthony
These should be equivalent, though technically 
@auth.requires_membership('Admin') is equivalent to @auth.requires(lambda: 
auth.has_membership(role='Admin')). Using the lambda prevents unnecessary 
database hits checking for membership in cases where the controller file is 
executed but the specific decorated function is not called.

Perhaps you can post a minimal app that reproduces the problem.

Anthony

On Sunday, February 10, 2013 11:40:45 PM UTC-5, 黄祥 wrote:

 hi,

 what is the difference within :
 @auth.requires_membership('Admin') and 
 @auth.requires(auth.has_membership(role = 'Admin'))
 it seems there is some limitation in @auth.requires_membership('Admin')

 e.g.
 *case 1 :*
 *as expected result*
 *@auth.requires(auth.has_membership(role = 'Admin')) ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 *unexpected result*
 *@auth.requires_membership('Admin') ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 what i mean for unexpected result is, the user with the membership of 
 group 'Admin' can not see the manage_blog page, when i modified it with 
 *@auth.requires(auth.has_membership(role 
 = 'Admin'))*, the user with the membership of group 'Admin' can see the 
 manage_blog page.

 is there anyone know about it?

 thank you so much in advance


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: reCaptcha in registration form with custom layout

2013-02-11 Thread Johan Börjesson
I had the same problem a while ago. The solution is described in the book: 
http://web2py.com/books/default/chapter/29/09#CAPTCHA-and-reCAPTCHA

Instead of 


 {{=form.custom.widget.recaptcha}}


use 

{{=FORM(Recaptcha(request,PUBLIC_KEY, PRIVATE_KEY, options=theme:'white'
))}} 

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Cannot label id field

2013-02-11 Thread Richard Vézina
I don't think you can change the representation of the id field you see in
smartgrid, you can hide with a switch :
https://groups.google.com/forum/#!msg/web2py/UYZE3G4hW2A/oqZdGeUa3xAJ

showid: false

If you read the thread I show the way I change representation of id with
SQLTABLE(), it may be adapted for Smartgrid...

But what you propose make no sens, because ID suppose to be unique for each
record and your label (representation) is the same for each record... You
need at least a mapping or using a URL redirection that will consider the
ID, so when you clic on it it bring you the read form of the other table
and record.

Hope it helps

Richard


On Sat, Feb 9, 2013 at 5:42 AM, François Delpierre 
francois.delpie...@gmail.com wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known to
 your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code'
 for the id field...
 Is this a bug?

 --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Integrating iPhone device tokens into web2py auth

2013-02-11 Thread howesc
Thanks Alec, that will be a nice contribution.

re my special odd pain in the rear-end login flow.well we (the 
engineers) failed to sell that to the business.  users can make purchases 
via apple without a proper logged in account, and we need to track those on 
the server.  hence the anonymous user.  it would be really nice if apple 
shared with us the itunes user ID on app launch, but they don't because 
they believe that violates the user's privacy (and i kinda agree on that 
point).  So i'm stuck with an overly complex login flow. :(

cfh

On Sunday, February 10, 2013 9:55:35 PM UTC-8, Alec Taylor wrote:

 Not to worry, I'm releasing a generalised open-source OAuth2 Library for 
 web2py. 

 As for your current mechanism of anonymous tokens… how about just 
 storing a cookie (or some other client-side storage) and when the user 
 logs-in or registers all their customisations (e.g.: if e-commerce, 
 their cart) will be sent securely to the server on receipt of 
 successful authentication. 

 That would be a much cleaner, more secure, streamlined and 
 self-contained model than your current one. 

 On Sun, Feb 10, 2013 at 9:33 AM, howesc how...@umich.edu javascript: 
 wrote: 
   - Apple explicitly does not allow using the hardware identifier in your 
  app, and will reject app submission that do that.  because of this each 
 app 
  install logs in first as an anonymous user. 
   - website users use standard web2py auth 
   - app connections to the server use our modified OAuth API 
 implementation. 
  this forgoes web2py auth, but reads and writes to the same user table 
 that 
  web2py auth uses.  this allows the 2 different systems to connect. 
   - the mobile apps are native code on their respective platforms, the 
  website is html. 
  
  unfortunately our modified OAuth implementation is pretty specific to 
 our 
  needs and so i don't think it's a candidate for us to open source.  i'll 
  take a look into what we are doing though to see if any of it can/should 
 be 
  open sourced. 
  
  cfh 
  
  
  On Saturday, February 9, 2013 11:40:50 AM UTC-8, Kenny wrote: 
  
  Howesc, 
  Thanks for great info. So, does mobile app user have to register web2py 
  via access token provided by their hardware in mobile application? May 
 you 
  explain how you built the login/registration module for mobile app 
 users 
  along with web2py? 
  Do you code in html5 with native code for developing your mobile app? 
  
  Sorry for asking more than one question, this topic sounds so 
 interesting! 
  :) 
  
  Thank you! 
  
  On Feb 9, 2013 11:45 AM, howesc how...@umich.edu wrote: 
  
  well what we are using is a hybrid model: 
   - the ios device uses a modified form of OAuth to get access tokens 
 (and 
  we have the confusing problem of users start anonymous but with an 
 access 
  token, and then may later create an account associating an email and 
 other 
  user data with the account) 
   - the website uses web2py's auth to login those same users 
   - the APNS token (Apple Push Notification Service) is provided 
  optionally by the user if they opt-in to push notifications.  as such 
 it's 
  not a primary key for the user and can't be used for authentication.   
 if 
  the user chooses to share it with us we store that in a field on our 
 user 
  table.  Note that the APNS token is device specific, so if the user 
 has 
  multiple devices then they might have multiple tokens. 
  
  does that clarify at all? 
  
  cfh 
  
  On Friday, February 8, 2013 9:46:42 PM UTC-8, Massimo Di Pierro wrote: 
  
  I do not know how this works. Can you give us more details? 
  
  On Friday, 8 February 2013 20:31:14 UTC-6, howesc wrote: 
  
  i have millions of APNS tokens! i'd share, but they are tied to an 
  app 
  
  i did not tie APNS tokesn to web2py auth, but i added fields to my 
 end 
  user table, and the device uses my REST JSON API to POST the APNS 
 tokens to 
  the server and update the user.  we don't use the APNS token as any 
 sort of 
  user identifier. 
  
  does that help?  lemme know if you are interested in more details. 
  
  christian 
  
  On Thursday, February 7, 2013 5:22:28 PM UTC-8, chris_g wrote: 
  
  I'm looking into supporting Apple push notifications in an iPhone 
 app 
  that connects to a web2py server. 
  In order to know which devices to push details to, web2py's auth 
  module would presumably need to maintain Device Tokens. 
  I'm curious if anyone has implemented a solution that takes care of 
  this. I'd like to see how it was integrated with web2py's auth. 
  
  Thanks, 
  Chris 
  
  -- 
  
  --- 
  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+un...@googlegroups.com. 
  
  For more options, visit https://groups.google.com/groups/opt_out. 
  
  
  
  -- 
  
  --- 
  You received this message because you are subscribed to the 

Re: [web2py] Cannot label id field

2013-02-11 Thread LightDot
Field label and representation are two different things...

A label is only displayed next to the field in generated forms. A visual 
aid, so to speak... Regardless of the label, the field itself would still 
be named id, it's format or representation would stay the same. François 
simply wants the field label to be displayed as Service Code instead of 
Id, which would be a default label.

I must say I never tried changing the label if an id. Off the top of my 
head, I can't think of a reason why it shouldn't be possible, so, yes, 
probably a bug.

Regards,
Ales


On Monday, February 11, 2013 6:01:42 PM UTC+1, Richard wrote:

 I don't think you can change the representation of the id field you see in 
 smartgrid, you can hide with a switch : 
 https://groups.google.com/forum/#!msg/web2py/UYZE3G4hW2A/oqZdGeUa3xAJ

 showid: false

 If you read the thread I show the way I change representation of id with 
 SQLTABLE(), it may be adapted for Smartgrid...

 But what you propose make no sens, because ID suppose to be unique for 
 each record and your label (representation) is the same for each record... 
 You need at least a mapping or using a URL redirection that will consider 
 the ID, so when you clic on it it bring you the read form of the other 
 table and record.

 Hope it helps

 Richard


 On Sat, Feb 9, 2013 at 5:42 AM, François Delpierre 
 francois@gmail.comjavascript:
  wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known to 
 your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code' 
 for the id field...
 Is this a bug?

 -- 
  
 --- 
 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+un...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] skyrocketing memory. How to pinpoint the problem?

2013-02-11 Thread Todd Shifflett
That's the thing.  When I remove all functionality of my app and simply create 
a new one whose only function is to return a json object of {test:memory} I 
see this behavior.  I was thinking that perhaps the memory was climbing because 
I was importing a module at the wrong place or something.

I'm going to go back and try to recreate this from a completely fresh web2py 
install, just in case Ive changed something that I don't remember.  I'll let 
you know what I find.  It's such a fantastic system, whatever I can do to help 
track it down so others don't bump into it somehow in the future.



On Feb 10, 2013, at 8:22 PM, Massimo Di Pierro wrote:

 2 requests/second seem slow. What does your app do? Look at 
 {{=response.toolbar()}} and see which DB query and how long they individually 
 take.

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Error in admin application when sessions expired or deploying new application

2013-02-11 Thread Massimo Di Pierro
appadmin still loads your model files first. There you are storing 
something in session that cannot be pickled.

On Monday, 11 February 2013 08:34:27 UTC-6, Mickael Corniere wrote:

 Hello Allan,

 The answer is no. As the application is the appadmin, I didn't change it. 
 I use the one given by web2py.

 Thx

 Le lundi 11 février 2013 15:28:14 UTC+1, Alan Etkin a écrit :

  I manage sometimes to deploy application by removing sessions file, bu 
 today impossible to make it works :'(

 Are you assigning to session a function/lambda?

 session.f = lambda x: x+1 # this is not legal



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: reCaptcha in registration form with custom layout

2013-02-11 Thread Massimo Di Pierro
Using a form inside a form may not a good idea. How about just:

{{=Recaptcha(request,PUBLIC_KEY, PRIVATE_KEY, options=theme:'white')}}

Would that work? Any suggestion for fixing this problem?

On Monday, 11 February 2013 09:13:15 UTC-6, Johan Börjesson wrote:

 I had the same problem a while ago. The solution is described in the book: 
 http://web2py.com/books/default/chapter/29/09#CAPTCHA-and-reCAPTCHA

 Instead of 


 {{=form.custom.widget.recaptcha}}


 use 

 {{=FORM(Recaptcha(request,PUBLIC_KEY, PRIVATE_KEY, options=theme:'white'
 ))}} 



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] skyrocketing memory. How to pinpoint the problem?

2013-02-11 Thread Massimo Di Pierro
Keep us posted. There is one thing that can cause a leak. Instantiating an 
object with __del__ method at every request. It is possible that a third 
party library does that if you import it and all one of its functions. 
Another thing is cache ram. Another is T(something) where something is 
request dependent. I cannot really think of anything else.



On Monday, 11 February 2013 11:49:12 UTC-6, pumplerod wrote:

 That's the thing.  When I remove all functionality of my app and simply 
 create a new one whose only function is to return a json object of 
 {test:memory} I see this behavior.  I was thinking that perhaps the 
 memory was climbing because I was importing a module at the wrong place or 
 something.

 I'm going to go back and try to recreate this from a completely fresh 
 web2py install, just in case Ive changed something that I don't remember. 
  I'll let you know what I find.  It's such a fantastic system, whatever I 
 can do to help track it down so others don't bump into it somehow in the 
 future.



 On Feb 10, 2013, at 8:22 PM, Massimo Di Pierro wrote:

 2 requests/second seem slow. What does your app do? Look at 
 {{=response.toolbar()}} and see which DB query and how long they 
 individually take.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Pre-populating a form with SQLFORM.factory

2013-02-11 Thread Tom Hines
Hello.  I want to use SQLFORM.factory() and pre-populate a form with values 
from the last form use.  Kind of like an update form.  It works some of the 
time, but I'm getting a lot of KeyError: 'id' exceptions.  There is no 'id' 
field.  Using web2py version 2.3.2.  Thanks for any help.

Example:

record = oldvals# oldvals are the old form.vars


form=SQLFORM.factory(
  Field(...),
  Field(...),
  ...,
  record=record)


Traceback (most recent call last):
  File ...\web2py\gluon\restricted.py, line 212, in restricted
exec ccode in environment
  File ... 
http://localhost:8000/admin/default/edit/intersection/controllers/query.py, 
line 2754, in module
  File ...\web2py\gluon\globals.py, line 193, in lambda
self._caller = lambda f: f()
  File ...\web2py\gluon\tools.py, line 2929, in f
return action(*a, **b)
  File ... 
http://localhost:8000/admin/default/edit/intersection/controllers/query.py, 
line 526, in ...
record=record
  File ...\web2py\gluon\sqlhtml.py, line 1546, in factory
**attributes)
  File ...\web2py\gluon\sqlhtml.py, line 1018, in __init__
self.record_id = str(record[field.name])
KeyError: 'id'

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Cannot label id field

2013-02-11 Thread Richard Vézina
My bad about, I miss understand...

Richard


On Mon, Feb 11, 2013 at 12:42 PM, LightDot light...@gmail.com wrote:

 Field label and representation are two different things...

 A label is only displayed next to the field in generated forms. A visual
 aid, so to speak... Regardless of the label, the field itself would still
 be named id, it's format or representation would stay the same. François
 simply wants the field label to be displayed as Service Code instead of
 Id, which would be a default label.

 I must say I never tried changing the label if an id. Off the top of my
 head, I can't think of a reason why it shouldn't be possible, so, yes,
 probably a bug.

 Regards,
 Ales



 On Monday, February 11, 2013 6:01:42 PM UTC+1, Richard wrote:

 I don't think you can change the representation of the id field you see
 in smartgrid, you can hide with a switch :
 https://groups.google.com/**forum/#!msg/web2py/**UYZE3G4hW2A/oqZdGeUa3xAJhttps://groups.google.com/forum/#!msg/web2py/UYZE3G4hW2A/oqZdGeUa3xAJ

 showid: false

 If you read the thread I show the way I change representation of id with
 SQLTABLE(), it may be adapted for Smartgrid...

 But what you propose make no sens, because ID suppose to be unique for
 each record and your label (representation) is the same for each record...
 You need at least a mapping or using a URL redirection that will consider
 the ID, so when you clic on it it bring you the read form of the other
 table and record.

 Hope it helps

 Richard


 On Sat, Feb 9, 2013 at 5:42 AM, François Delpierre 
 francois@gmail.com wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known to
 your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code'
 for the id field...
 Is this a bug?

 --

 ---
 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+un...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Error in admin application when sessions expired or deploying new application

2013-02-11 Thread Mickael Corniere
Thx Massimo I will check


2013/2/11 Massimo Di Pierro massimo.dipie...@gmail.com

 appadmin still loads your model files first. There you are storing
 something in session that cannot be pickled.


 On Monday, 11 February 2013 08:34:27 UTC-6, Mickael Corniere wrote:

 Hello Allan,

 The answer is no. As the application is the appadmin, I didn't change it.
 I use the one given by web2py.

 Thx

 Le lundi 11 février 2013 15:28:14 UTC+1, Alan Etkin a écrit :

  I manage sometimes to deploy application by removing sessions file, bu
 today impossible to make it works :'(

 Are you assigning to session a function/lambda?

 session.f = lambda x: x+1 # this is not legal

  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: clear data session

2013-02-11 Thread 黄祥
hi anthony,

here is the code :
*# controller *
def order_callback():
id=int(request.vars.id)
if request.vars.action=='add':
session.order[id]=session.order.get(id, 0)+1
if request.vars.action=='sub':
session.order[id]=max(0,session.order.get(id, 0)-1)
*#if request.vars.action=='remove':*
*#   session.order[id]=session.order.clear()*
*if request.vars.action=='remove':
*
*session.order[id]=session.clear()*
return str(session.order[id])

*#view order.html*
table width=100%
{{for id, qty in order.items():}}
{{p=db.product(id)}}
tr
td{{=p.product_name}}/td
tdRp. {{=p.unit_price}}/td
tdspan id={{='item%s'%p.id}}{{=qty}}/span
{{=SPAN(A('Add', callback=URL('order_callback', vars=dict(id=p.id, 
action='add')), target='item%s'%p.id, _title='Add the Order', _class='btn 
btn-navbar'))}} {{=SPAN(A('Sub', callback=URL('order_callback', 
vars=dict(id=p.id, action='sub')), target='item%s'%p.id, _title='Substract 
the Order', _class='btn btn-navbar'))}} *{{=SPAN(A('Remove', 
callback=URL('order_callback', vars=dict(id=p.id, action='remove')), 
target='item%s'%p.id, _title='Remove the Order', _class='btn btn-navbar'))}}
*/td
/tr
{{pass}}
/table

the code is learned from pos online store (appliance), i've tried to add 
remove function so that the product that user click can be remove as well 
(not just add and subtract).
if tried both session.order.clear() and session.clear() in controller but 
all of it is not work.
please show me the part that i make it wrong.
thank you so much in advance before

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Cannot label id field

2013-02-11 Thread Richard Vézina
Too me it is not a bug, since there is a button to acces those records
(read or update), I don't see why you want the id to be include in the
grid, so... showid: false and rely on the grid button should be all right.

Richard


On Mon, Feb 11, 2013 at 1:06 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 My bad about, I miss understand...

 Richard


 On Mon, Feb 11, 2013 at 12:42 PM, LightDot light...@gmail.com wrote:

 Field label and representation are two different things...

 A label is only displayed next to the field in generated forms. A visual
 aid, so to speak... Regardless of the label, the field itself would still
 be named id, it's format or representation would stay the same. François
 simply wants the field label to be displayed as Service Code instead of
 Id, which would be a default label.

 I must say I never tried changing the label if an id. Off the top of my
 head, I can't think of a reason why it shouldn't be possible, so, yes,
 probably a bug.

 Regards,
 Ales



 On Monday, February 11, 2013 6:01:42 PM UTC+1, Richard wrote:

 I don't think you can change the representation of the id field you see
 in smartgrid, you can hide with a switch :
 https://groups.google.com/**forum/#!msg/web2py/**
 UYZE3G4hW2A/oqZdGeUa3xAJhttps://groups.google.com/forum/#!msg/web2py/UYZE3G4hW2A/oqZdGeUa3xAJ

 showid: false

 If you read the thread I show the way I change representation of id with
 SQLTABLE(), it may be adapted for Smartgrid...

 But what you propose make no sens, because ID suppose to be unique for
 each record and your label (representation) is the same for each record...
 You need at least a mapping or using a URL redirection that will consider
 the ID, so when you clic on it it bring you the read form of the other
 table and record.

 Hope it helps

 Richard


 On Sat, Feb 9, 2013 at 5:42 AM, François Delpierre 
 francois@gmail.com wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known
 to your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code'
 for the id field...
 Is this a bug?

 --

 ---
 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+un...@**googlegroups.com.

 For more options, visit 
 https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
 .




  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.






-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: @auth.requires_membership('Admin') and @auth.requires(auth.has_membership(role = 'Admin'))

2013-02-11 Thread 黄祥
hi anthony,

thank for your explaination, but i'm sorry, i'm still not understand. i've 
already tried to learn from trial and error like the code that i've shown 
above. the unexpected result above, is mean that i can not view the page 
that is authorize to me (as an *admin membership*). the strange behaviour 
on my second post is when i submit the data in form, it won't work.
my goal is to set the function that can be used by another function. let 
say __grid_0() can be used by manage_blog() and manage_news() for example

here is the code that i'm tried :
*#model*
db.define_table('blog',
Field('title'),
Field('contents', 'text'),
format='%(title)s')

#controller work for a moment
# pagination function
def __pagination_0(flash, table, active):
response.flash=T(flash)
if len(request.args): 
page=int(request.args[0])
else: 
page=0
items_per_page=10
limitby=(page*items_per_page, (page+1)*items_per_page+1)
rows=db(active==True).select(limitby=limitby, orderby=~table.id,
 cache=(cache.ram, 10))
return dict(rows=rows, page=page, items_per_page=items_per_page)

# grid function
@auth.requires(auth.has_membership(role = 'Admin'))
def __grid_0(flash, table):
response.flash=T(flash)
has_membership=auth.has_membership('Admin')
grid=SQLFORM.smartgrid(table, user_signature=False, 
onupdate=auth.archive, 
   create=has_membership, editable=has_membership,
   deletable=has_membership)
return dict(grid=grid)

blog_flash=Blog
blog_db=db.blog
blog_active=db.blog.is_active
blog_manage_flash=Manage Blog

# blog
def blog():
return __pagination_0(blog_flash, blog_db, blog_active)

# manage_blog
def manage_blog():
return __grid_0(blog_manage_flash, blog_db)

*#view*
*blog.html*
{{extend 'layout.html'}}

{{for i,row in enumerate(rows):}}
{{if i==items_per_page: break}}
{{=DIV(H2(row.title))}}
{{=DIV(row.contents)}}
{{=prettydate(row.created_on)}}
{{=BR()}}
{{pass}}

{{if page:}}
{{=SPAN(A(T(' Previous'), _href=URL(args=[page-1]), _title=T('Previous 
Page')))}}
{{pass}}

{{if len(rows)  items_per_page:}}
{{=SPAN(A(T('Next '), _href=URL(args=[page+1]), _title=T('Next Page')))}}
{{pass}}

*manage_blog.html*
{{extend 'layout.html'}}

{{=grid}}

On Monday, February 11, 2013 9:49:29 PM UTC+7, Anthony wrote:

 These should be equivalent, though technically 
 @auth.requires_membership('Admin') is equivalent to @auth.requires(lambda: 
 auth.has_membership(role='Admin')). Using the lambda prevents unnecessary 
 database hits checking for membership in cases where the controller file is 
 executed but the specific decorated function is not called.

 Perhaps you can post a minimal app that reproduces the problem.

 Anthony

 On Sunday, February 10, 2013 11:40:45 PM UTC-5, 黄祥 wrote:

 hi,

 what is the difference within :
 @auth.requires_membership('Admin') and 
 @auth.requires(auth.has_membership(role = 'Admin'))
 it seems there is some limitation in @auth.requires_membership('Admin')

 e.g.
 *case 1 :*
 *as expected result*
 *@auth.requires(auth.has_membership(role = 'Admin')) ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 *unexpected result*
 *@auth.requires_membership('Admin') ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 what i mean for unexpected result is, the user with the membership of 
 group 'Admin' can not see the manage_blog page, when i modified it with 
 *@auth.requires(auth.has_membership(role 
 = 'Admin'))*, the user with the membership of group 'Admin' can see the 
 manage_blog page.

 is there anyone know about it?

 thank you so much in advance



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Pre-populating a form with SQLFORM.factory

2013-02-11 Thread Massimo Di Pierro
form=SQLFORM.factory(
  Field(...),
  Field(...)).process(keepvalues=True)

On Monday, 11 February 2013 10:56:54 UTC-6, Tom Hines wrote:

 Hello.  I want to use SQLFORM.factory() and pre-populate a form with 
 values from the last form use.  Kind of like an update form.  It works some 
 of the time, but I'm getting a lot of KeyError: 'id' exceptions.  There 
 is no 'id' field.  Using web2py version 2.3.2.  Thanks for any help.

 Example:

 record = oldvals# oldvals are the old form.vars


 form=SQLFORM.factory(
   Field(...),
   Field(...),
   ...,
   record=record)


 Traceback (most recent call last):
   File ...\web2py\gluon\restricted.py, line 212, in restricted
 exec ccode in environment
   File ... 
 http://localhost:8000/admin/default/edit/intersection/controllers/query.py, 
 line 2754, in module
   File ...\web2py\gluon\globals.py, line 193, in lambda
 self._caller = lambda f: f()
   File ...\web2py\gluon\tools.py, line 2929, in f
 return action(*a, **b)
   File ... 
 http://localhost:8000/admin/default/edit/intersection/controllers/query.py, 
 line 526, in ...
 record=record
   File ...\web2py\gluon\sqlhtml.py, line 1546, in factory
 **attributes)
   File ...\web2py\gluon\sqlhtml.py, line 1018, in __init__
 self.record_id = str(record[field.name])
 KeyError: 'id'



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: @auth.requires_membership('Admin') and @auth.requires(auth.has_membership(role = 'Admin'))

2013-02-11 Thread Massimo Di Pierro
Please open a ticket about this and link this thread. they should work the 
same. I never had a problem with it but we will take a second look.

On Monday, 11 February 2013 12:32:05 UTC-6, 黄祥 wrote:

 hi anthony,

 thank for your explaination, but i'm sorry, i'm still not understand. i've 
 already tried to learn from trial and error like the code that i've shown 
 above. the unexpected result above, is mean that i can not view the page 
 that is authorize to me (as an *admin membership*). the strange behaviour 
 on my second post is when i submit the data in form, it won't work.
 my goal is to set the function that can be used by another function. let 
 say __grid_0() can be used by manage_blog() and manage_news() for example

 here is the code that i'm tried :
 *#model*
 db.define_table('blog',
 Field('title'),
 Field('contents', 'text'),
 format='%(title)s')

 #controller work for a moment
 # pagination function
 def __pagination_0(flash, table, active):
 response.flash=T(flash)
 if len(request.args): 
 page=int(request.args[0])
 else: 
 page=0
 items_per_page=10
 limitby=(page*items_per_page, (page+1)*items_per_page+1)
 rows=db(active==True).select(limitby=limitby, orderby=~table.id,
  cache=(cache.ram, 10))
 return dict(rows=rows, page=page, items_per_page=items_per_page)

 # grid function
 @auth.requires(auth.has_membership(role = 'Admin'))
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, user_signature=False, 
 onupdate=auth.archive, 
create=has_membership, editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 blog_flash=Blog
 blog_db=db.blog
 blog_active=db.blog.is_active
 blog_manage_flash=Manage Blog

 # blog
 def blog():
 return __pagination_0(blog_flash, blog_db, blog_active)

 # manage_blog
 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 *#view*
 *blog.html*
 {{extend 'layout.html'}}

 {{for i,row in enumerate(rows):}}
 {{if i==items_per_page: break}}
 {{=DIV(H2(row.title))}}
 {{=DIV(row.contents)}}
 {{=prettydate(row.created_on)}}
 {{=BR()}}
 {{pass}}

 {{if page:}}
 {{=SPAN(A(T(' Previous'), _href=URL(args=[page-1]), _title=T('Previous 
 Page')))}}
 {{pass}}

 {{if len(rows)  items_per_page:}}
 {{=SPAN(A(T('Next '), _href=URL(args=[page+1]), _title=T('Next Page')))}}
 {{pass}}

 *manage_blog.html*
 {{extend 'layout.html'}}

 {{=grid}}

 On Monday, February 11, 2013 9:49:29 PM UTC+7, Anthony wrote:

 These should be equivalent, though technically 
 @auth.requires_membership('Admin') is equivalent to @auth.requires(lambda: 
 auth.has_membership(role='Admin')). Using the lambda prevents 
 unnecessary database hits checking for membership in cases where the 
 controller file is executed but the specific decorated function is not 
 called.

 Perhaps you can post a minimal app that reproduces the problem.

 Anthony

 On Sunday, February 10, 2013 11:40:45 PM UTC-5, 黄祥 wrote:

 hi,

 what is the difference within :
 @auth.requires_membership('Admin') and 
 @auth.requires(auth.has_membership(role = 'Admin'))
 it seems there is some limitation in @auth.requires_membership('Admin')

 e.g.
 *case 1 :*
 *as expected result*
 *@auth.requires(auth.has_membership(role = 'Admin')) ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 *unexpected result*
 *@auth.requires_membership('Admin') ### the difference*
 def __grid_0(flash, table):
 response.flash=T(flash)
 has_membership=auth.has_membership('Admin')
 grid=SQLFORM.smartgrid(table, onupdate=auth.archive,
create=has_membership,
editable=has_membership,
deletable=has_membership)
 return dict(grid=grid)

 def manage_blog():
 return __grid_0(blog_manage_flash, blog_db)

 what i mean for unexpected result is, the user with the membership of 
 group 'Admin' can not see the manage_blog page, when i modified it with 
 *@auth.requires(auth.has_membership(role = 'Admin'))*, the user with 
 the membership of group 'Admin' can see the manage_blog page.

 is there anyone know about it?

 thank you so much in advance



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit 

[web2py] Re: Cannot label id field

2013-02-11 Thread Derek
Seems to work for me.

db.define_table('customers',
Field('name', 'string',length=50, requires=IS_NOT_EMPTY()),
   ...
Field('country','string',length=3),
Field('active','boolean'),format='%(name)s', singular='customer', 
plural='customers')
db.customers.id.label=T('TEST ID')

On web2py 2.3.2

On Saturday, February 9, 2013 3:42:50 AM UTC-7, François Delpierre wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known to 
 your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code' 
 for the id field...
 Is this a bug?


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: clear data session

2013-02-11 Thread Derek
why are you not doing this:

* if request.vars.action=='remove':*
*del session.order[id]*
*
*On Monday, February 11, 2013 11:16:52 AM UTC-7, 黄祥 wrote:

 hi anthony,

 here is the code :
 *# controller *
 def order_callback():
 id=int(request.vars.id)
 if request.vars.action=='add':
 session.order[id]=session.order.get(id, 0)+1
 if request.vars.action=='sub':
 session.order[id]=max(0,session.order.get(id, 0)-1)
 *#if request.vars.action=='remove':*
 *#   session.order[id]=session.order.clear()*
 *if request.vars.action=='remove':
 *
 *session.order[id]=session.clear()*
 return str(session.order[id])

 *#view order.html*
 table width=100%
 {{for id, qty in order.items():}}
 {{p=db.product(id)}}
 tr
 td{{=p.product_name}}/td
 tdRp. {{=p.unit_price}}/td
 tdspan id={{='item%s'%p.id}}{{=qty}}/span
 {{=SPAN(A('Add', callback=URL('order_callback', vars=dict(id=p.id, 
 action='add')), target='item%s'%p.id, _title='Add the Order', _class='btn 
 btn-navbar'))}} {{=SPAN(A('Sub', callback=URL('order_callback', 
 vars=dict(id=p.id, action='sub')), target='item%s'%p.id, 
 _title='Substract the Order', _class='btn btn-navbar'))}} 
 *{{=SPAN(A('Remove', 
 callback=URL('order_callback', vars=dict(id=p.id, action='remove')), 
 target='item%s'%p.id, _title='Remove the Order', _class='btn 
 btn-navbar'))}}*/td
 /tr
 {{pass}}
 /table

 the code is learned from pos online store (appliance), i've tried to add 
 remove function so that the product that user click can be remove as well 
 (not just add and subtract).
 if tried both session.order.clear() and session.clear() in controller but 
 all of it is not work.
 please show me the part that i make it wrong.
 thank you so much in advance before


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to use a text file instead of a db?

2013-02-11 Thread Niphlod
open the file, read it and do what you need to do. your question leaves 
a lot of holes about what you're trying to do.

On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote:

 I have a text file and want to generate a page using that file's contents 
 instead of querying a db. 

 I have looked at all the web2py-appliances but could not find an example. 

 I create the text file, so I can make it any format. 



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Cannot label id field

2013-02-11 Thread Richard Vézina
I just look again at the model of François and I think there is a mistake,
because id field should not be of type integer when you explicitly define
them in your model

type='id' is the proper type, so maybe he has 2 differents columns named id
or his model doesn't really works.

Ref.: http://web2py.com/books/default/chapter/29/06#DAL,-Table,-Field

Richard


On Mon, Feb 11, 2013 at 1:55 PM, Derek sp1d...@gmail.com wrote:

 Seems to work for me.

 db.define_table('customers',
 Field('name', 'string',length=50, requires=IS_NOT_EMPTY()),
...
 Field('country','string',length=3),
 Field('active','boolean'),format='%(name)s', singular='customer',
 plural='customers')
 db.customers.id.label=T('TEST ID')

 On web2py 2.3.2

 On Saturday, February 9, 2013 3:42:50 AM UTC-7, François Delpierre wrote:

 Hi,

 Let's see the definition:

 db.define_table('t_bsc',
 Field('id', type='integer', label=T('Service Code')),
 Field('f_name', type='string',
   label=T('Service name'),
   comment=T('The name of the customer facing service as known to
 your customer.')),

 But in my smartgrid, I still see the label Id instead of 'Service Code'
 for the id field...
 Is this a bug?

  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: clear data session

2013-02-11 Thread Anthony
*session.order[id]=session.clear()*
*
*
I would think the above would generate an error -- session.clear() empties 
the session object (and returns None), and then you attempt to assign to 
session.order[id], even though session.order no longer exists. Assuming 
session.order is a list, session.order.clear() would also generate an 
error, as .clear() is not a method of lists. As Derek suggested, you can 
use del to remove an item from a list.

Anthony

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: serving php and python in shared hosting

2013-02-11 Thread José Eloy
Thanks to all for your help. I'll share with you all my progress.

Well, first I created a subdomain: 
http://www.administracionjoomla.transicion.mx. In /www I created a folder 
called joomla, inside I copied all the joomla instalation. For access 
joomla site I had to go http://www.administracionjoomla.transicion.mx/joomla. 
The first time i wanted access the joomla site the web browser send me a 
Invalid Request message. Then I rename the htaccess.txt file (in joomla 
folder) to .htacess. I pressed the F5 key again and voilá! the joomla site 
worked!. But, after pressed several times the F5 I got again: Invalid 
Request. I opened an ssh terminal and wrote: ps ax, and I got a lot of of 
dispafth.fcgi instance running, I kill them and pressed F5 in my web 
browser and the joomla site worked again.

I still have many questions...

Why I have a lot of dispatch.fcgi process? I noted the number of this 
process increase every time the web2py app is invoked.

Does anybody have an answer?

P. D. Sorry for my English. Is not very well

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to use a text file instead of a db?

2013-02-11 Thread Derek
put it in /static and access it by name.


On Monday, February 11, 2013 1:54:34 PM UTC-7, rh wrote:

 On Mon, 11 Feb 2013 11:33:56 -0800 (PST) 
 Niphlod nip...@gmail.com javascript: wrote: 

  open the file, read it and do what you need to do. your question 
  leaves a lot of holes about what you're trying to do. 

 Not sure what you mean about holes, I did find an example right under 
 my nose in the admin app. 

 I have a file. 
 I want to read in the contents. 
 I want to display those contents when a page is visited. 

 What more can I say about that? 

  
  On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote: 
   
   I have a text file and want to generate a page using that file's 
   contents instead of querying a db. 
   
   I have looked at all the web2py-appliances but could not find an 
   example. 
   
   I create the text file, so I can make it any format. 
   
   
  
  -- 
  
  --- 
  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 
  +unsub...@googlegroups.com javascript:. For 
  more options, visit https://groups.google.com/groups/opt_out. 
  
  


 -- 




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Pre-populating a form with SQLFORM.factory

2013-02-11 Thread Tom Hines
Thank you.  That works.  Now I'm keeping the form history and letting the 
user select any previous set of values.  I have found that this works for 
me:

record = oldvals# oldvals are from a previous form.vars
record['id'] = ''

form=SQLFORM.factory(
  Field(...),
  Field(...),
  ...,
  record=record,
  showid=False
)



On Monday, February 11, 2013 1:38:01 PM UTC-5, Massimo Di Pierro wrote:

 form=SQLFORM.factory(
   Field(...),
   Field(...)).process(keepvalues=True)

 On Monday, 11 February 2013 10:56:54 UTC-6, Tom Hines wrote:

 Hello.  I want to use SQLFORM.factory() and pre-populate a form with 
 values from the last form use.  Kind of like an update form.  It works some 
 of the time, but I'm getting a lot of KeyError: 'id' exceptions.  There 
 is no 'id' field.  Using web2py version 2.3.2.  Thanks for any help.

 Example:

 record = oldvals# oldvals are the old form.vars


 form=SQLFORM.factory(
   Field(...),
   Field(...),
   ...,
   record=record)


 Traceback (most recent call last):
   File ...\web2py\gluon\restricted.py, line 212, in restricted
 exec ccode in environment
   File ... 
 http://localhost:8000/admin/default/edit/intersection/controllers/query.py,
  line 2754, in module
   File ...\web2py\gluon\globals.py, line 193, in lambda
 self._caller = lambda f: f()
   File ...\web2py\gluon\tools.py, line 2929, in f
 return action(*a, **b)
   File ... 
 http://localhost:8000/admin/default/edit/intersection/controllers/query.py,
  line 526, in ...
 record=record
   File ...\web2py\gluon\sqlhtml.py, line 1546, in factory
 **attributes)
   File ...\web2py\gluon\sqlhtml.py, line 1018, in __init__
 self.record_id = str(record[field.name])
 KeyError: 'id'



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to use a text file instead of a db?

2013-02-11 Thread Niphlod
ehm
put the file somewhere reachable by your app. Let's say you put a file 
hello.txt into the private/ folder.

import os
def myfunction():
filepath = os.path.join(request.folder, private, hello.txt)
with open(filepath) as g:
content = g.read()
return dict(content=content)



On Monday, February 11, 2013 9:54:34 PM UTC+1, rh wrote:

 On Mon, 11 Feb 2013 11:33:56 -0800 (PST) 
 Niphlod nip...@gmail.com javascript: wrote: 

  open the file, read it and do what you need to do. your question 
  leaves a lot of holes about what you're trying to do. 

 Not sure what you mean about holes, I did find an example right under 
 my nose in the admin app. 

 I have a file. 
 I want to read in the contents. 
 I want to display those contents when a page is visited. 

 What more can I say about that? 

  
  On Monday, February 11, 2013 7:52:38 PM UTC+1, rh wrote: 
   
   I have a text file and want to generate a page using that file's 
   contents instead of querying a db. 
   
   I have looked at all the web2py-appliances but could not find an 
   example. 
   
   I create the text file, so I can make it any format. 
   
   
  
  -- 
  
  --- 
  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 
  +unsub...@googlegroups.com javascript:. For 
  more options, visit https://groups.google.com/groups/opt_out. 
  
  


 -- 




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Integrating iPhone device tokens into web2py auth

2013-02-11 Thread Kenny Chung
Thank you, guys. :) I think I should try to implement one, when I am free.

Do you know any opensource for  iphone oauth login as well as android?

I am actually passing login credentials to web2py from android app via
given web2py lib.
On Feb 11, 2013 11:29 AM, howesc how...@umich.edu wrote:

 Thanks Alec, that will be a nice contribution.

 re my special odd pain in the rear-end login flow.well we (the
 engineers) failed to sell that to the business.  users can make purchases
 via apple without a proper logged in account, and we need to track those on
 the server.  hence the anonymous user.  it would be really nice if apple
 shared with us the itunes user ID on app launch, but they don't because
 they believe that violates the user's privacy (and i kinda agree on that
 point).  So i'm stuck with an overly complex login flow. :(

 cfh

 On Sunday, February 10, 2013 9:55:35 PM UTC-8, Alec Taylor wrote:

 Not to worry, I'm releasing a generalised open-source OAuth2 Library for
 web2py.

 As for your current mechanism of anonymous tokens… how about just
 storing a cookie (or some other client-side storage) and when the user
 logs-in or registers all their customisations (e.g.: if e-commerce,
 their cart) will be sent securely to the server on receipt of
 successful authentication.

 That would be a much cleaner, more secure, streamlined and
 self-contained model than your current one.

 On Sun, Feb 10, 2013 at 9:33 AM, howesc how...@umich.edu wrote:
   - Apple explicitly does not allow using the hardware identifier in
 your
  app, and will reject app submission that do that.  because of this each
 app
  install logs in first as an anonymous user.
   - website users use standard web2py auth
   - app connections to the server use our modified OAuth API
 implementation.
  this forgoes web2py auth, but reads and writes to the same user table
 that
  web2py auth uses.  this allows the 2 different systems to connect.
   - the mobile apps are native code on their respective platforms, the
  website is html.
 
  unfortunately our modified OAuth implementation is pretty specific to
 our
  needs and so i don't think it's a candidate for us to open source.
  i'll
  take a look into what we are doing though to see if any of it
 can/should be
  open sourced.
 
  cfh
 
 
  On Saturday, February 9, 2013 11:40:50 AM UTC-8, Kenny wrote:
 
  Howesc,
  Thanks for great info. So, does mobile app user have to register
 web2py
  via access token provided by their hardware in mobile application? May
 you
  explain how you built the login/registration module for mobile app
 users
  along with web2py?
  Do you code in html5 with native code for developing your mobile app?
 
  Sorry for asking more than one question, this topic sounds so
 interesting!
  :)
 
  Thank you!
 
  On Feb 9, 2013 11:45 AM, howesc how...@umich.edu wrote:
 
  well what we are using is a hybrid model:
   - the ios device uses a modified form of OAuth to get access tokens
 (and
  we have the confusing problem of users start anonymous but with an
 access
  token, and then may later create an account associating an email
 and other
  user data with the account)
   - the website uses web2py's auth to login those same users
   - the APNS token (Apple Push Notification Service) is provided
  optionally by the user if they opt-in to push notifications.  as such
 it's
  not a primary key for the user and can't be used for authentication.
   if
  the user chooses to share it with us we store that in a field on our
 user
  table.  Note that the APNS token is device specific, so if the user
 has
  multiple devices then they might have multiple tokens.
 
  does that clarify at all?
 
  cfh
 
  On Friday, February 8, 2013 9:46:42 PM UTC-8, Massimo Di Pierro
 wrote:
 
  I do not know how this works. Can you give us more details?
 
  On Friday, 8 February 2013 20:31:14 UTC-6, howesc wrote:
 
  i have millions of APNS tokens! i'd share, but they are tied to an
  app
 
  i did not tie APNS tokesn to web2py auth, but i added fields to my
 end
  user table, and the device uses my REST JSON API to POST the APNS
 tokens to
  the server and update the user.  we don't use the APNS token as any
 sort of
  user identifier.
 
  does that help?  lemme know if you are interested in more details.
 
  christian
 
  On Thursday, February 7, 2013 5:22:28 PM UTC-8, chris_g wrote:
 
  I'm looking into supporting Apple push notifications in an iPhone
 app
  that connects to a web2py server.
  In order to know which devices to push details to, web2py's auth
  module would presumably need to maintain Device Tokens.
  I'm curious if anyone has implemented a solution that takes care
 of
  this. I'd like to see how it was integrated with web2py's auth.
 
  Thanks,
  Chris
 
  --
 
  ---
  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] Re: clear data session

2013-02-11 Thread Michael Beller
Hi Hai,

I've also used posonlinestore as a basis for an application.

I also added a remove option and used del session.cart[id] to remove an 
item from the cart (it looks like you're using order instead of cart.

I used session.cart.clear() to empty the cart after I processed the order 
and inserted the cart items into the database.

Mike

On Monday, February 11, 2013 8:30:49 AM UTC-5, 黄祥 wrote:

 hai,

 is there a way to clear data session?
 i've tried session.clear() it seems not work
 any help is greatly appreciate.

 many thanks in advance


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Simple routing question

2013-02-11 Thread Jim S
I'm trying to route traffic that comes in on a specific URL to a specifc 
app.

Example:

www.host1.com should route to the welcome app

www.host2.com should route to mySpecific app

I realize this is probably trivial, but I'm really struggling with it. 
 Hoping to do it with routes.py and not through wsgi stuff.  Please feel 
free to set me straight if that is not advisable.

-Jim

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jonathan Lundell
On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com wrote:
 I'm trying to route traffic that comes in on a specific URL to a specifc app.
 
 Example:
 
 www.host1.com should route to the welcome app
 
 www.host2.com should route to mySpecific app
 
 I realize this is probably trivial, but I'm really struggling with it.  
 Hoping to do it with routes.py and not through wsgi stuff.  Please feel free 
 to set me straight if that is not advisable.
 

Look at the domain-routing provision in the parametric router. Documentation in 
the book, and in router.example.py.

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jim S
Jonathan

I am currently using that as my base for getting this working.  Here is 
what I have so far:

routers = dict(
# base router
BASE=dict(domains = {www.website1.com:mustangs,
www.website2.com:icysa, }))

But, anytime I to either URL, I get the web2py welcome app.

Also, I've saved the file as routes.py.

-Jim

On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:

 On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com javascript: wrote:

 I'm trying to route traffic that comes in on a specific URL to a specifc 
 app.

 Example:

 www.host1.com should route to the welcome app

 www.host2.com should route to mySpecific app

 I realize this is probably trivial, but I'm really struggling with it. 
  Hoping to do it with routes.py and not through wsgi stuff.  Please feel 
 free to set me straight if that is not advisable.


 Look at the domain-routing provision in the parametric router. 
 Documentation in the book, and in router.example.py.


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jonathan Lundell
On 11 Feb 2013, at 7:01 PM, Jim S j...@qlf.com wrote:
 Jonathan
 
 I am currently using that as my base for getting this working.  Here is what 
 I have so far:
 
 routers = dict(
 # base router
 BASE=dict(domains = {www.website1.com:mustangs,
 www.website2.com:icysa, }))
 
 But, anytime I to either URL, I get the web2py welcome app.
 
 Also, I've saved the file as routes.py.

And restarted, right?

Try turning on logging for routes and see what you get. You might also examine 
request.env, and make sure that the target domain is showing up properly.

 
 -Jim
 
 On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:
 On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com wrote:
 I'm trying to route traffic that comes in on a specific URL to a specifc app.
 
 Example:
 
 www.host1.com should route to the welcome app
 
 www.host2.com should route to mySpecific app
 
 I realize this is probably trivial, but I'm really struggling with it.  
 Hoping to do it with routes.py and not through wsgi stuff.  Please feel free 
 to set me straight if that is not advisable.
 
 
 Look at the domain-routing provision in the parametric router. Documentation 
 in the book, and in router.example.py.
 
 -- 
  



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jim Steil
Sorry for being slow at this, route configuration is certainly not a forte
of mine.  Is there something special I need to do to turn on logging?  How
would I examine request.env?  I'm running all of this from pythonanywhere
and don't really know where to find these things.

-Jim

On Mon, Feb 11, 2013 at 9:06 PM, Jonathan Lundell jlund...@pobox.comwrote:

 On 11 Feb 2013, at 7:01 PM, Jim S j...@qlf.com wrote:

 Jonathan

 I am currently using that as my base for getting this working.  Here is
 what I have so far:

 routers = dict(
 # base router
 BASE=dict(domains = {www.website1.com:mustangs,
 www.website2.com:icysa, }))

 But, anytime I to either URL, I get the web2py welcome app.

 Also, I've saved the file as routes.py.


 And restarted, right?

 Try turning on logging for routes and see what you get. You might also
 examine request.env, and make sure that the target domain is showing up
 properly.


 -Jim

 On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:

 On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com wrote:

 I'm trying to route traffic that comes in on a specific URL to a specifc
 app.

 Example:

 www.host1.com should route to the welcome app

 www.host2.com should route to mySpecific app

 I realize this is probably trivial, but I'm really struggling with it.
  Hoping to do it with routes.py and not through wsgi stuff.  Please feel
 free to set me straight if that is not advisable.


 Look at the domain-routing provision in the parametric router.
 Documentation in the book, and in router.example.py.


 --





  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jim S
...and yes, restarted.

On Monday, February 11, 2013 9:48:59 PM UTC-6, Jim S wrote:

 Sorry for being slow at this, route configuration is certainly not a forte 
 of mine.  Is there something special I need to do to turn on logging?  How 
 would I examine request.env?  I'm running all of this from pythonanywhere 
 and don't really know where to find these things.

 -Jim

 On Mon, Feb 11, 2013 at 9:06 

 Jonathan

 I am currently using that as my base for getting this working.  Here is 
 what I have so far:

 routers = dict(
 # base router
 BASE=dict(domains = {www.website1.com:mustangs,
 www.website2.com:icysa, }))

 But, anytime I to either URL, I get the web2py welcome app.

 Also, I've saved the file as routes.py.


 And restarted, right?

 Try turning on logging for routes and see what you get. You might also 
 examine request.env, and make sure that the target domain is showing up 
 properly.


 -Jim

 On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:

 On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com wrote:

 I'm trying to route traffic that comes in on a specific URL to a specifc 
 app.

 Example:

 www.host1.com should route to the welcome app

 www.host2.com should route to mySpecific app

 I realize this is probably trivial, but I'm really struggling with it. 
  Hoping to do it with routes.py and not through wsgi stuff.  Please feel 
 free to set me straight if that is not advisable.


 Look at the domain-routing provision in the parametric router. 
 Documentation in the book, and in router.example.py.


 -- 
  




  -- 
  
 --- 
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Integrating iPhone device tokens into web2py auth

2013-02-11 Thread Alec Taylor
On Tue, Feb 12, 2013 at 4:29 AM, howesc how...@umich.edu wrote:
 Thanks Alec, that will be a nice contribution.

 re my special odd pain in the rear-end login flow.well we (the
 engineers) failed to sell that to the business.  users can make purchases
 via apple without a proper logged in account, and we need to track those on
 the server.  hence the anonymous user.  it would be really nice if apple
 shared with us the itunes user ID on app launch, but they don't because they
 believe that violates the user's privacy (and i kinda agree on that point).
 So i'm stuck with an overly complex login flow. :(

 cfh

How do you differentiate between different anonymous users?

Are you looking at MAC address or other related IDs?

It sounds to me that that's still an open problem. And that not
generating any ID but storing data in LocalStorage (or a cookie; or
whatever else: locally) would be the most secure way of confirming
accountability.

Given an e-commerce scenario; on checkout the anonymous user would
submit their entire LocalStorage; which obviously includes cart. Their
shipping details and whatnot would include an email address, so create
them that profile; log them in; and email them their randomly
generated password.

#problem=solved

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Simple routing question

2013-02-11 Thread Jonathan Lundell
On 11 Feb 2013, at 7:48 PM, Jim Steil ato.st...@gmail.com wrote:
 Sorry for being slow at this, route configuration is certainly not a forte of 
 mine.  Is there something special I need to do to turn on logging?  How would 
 I examine request.env?  I'm running all of this from pythonanywhere and don't 
 really know where to find these things.


=BEAUTIFY(request) or =BEAUTIFY(request.env) should do the trick.

Logging depends on your deployment, but it's worth figuring out. Look at 
logging.example.conf. You can set the loglevel of routing in routes.py.

It's really too bad that logging is such a pain to get configured, because it's 
really valuable.

 
 -Jim
 
 On Mon, Feb 11, 2013 at 9:06 PM, Jonathan Lundell jlund...@pobox.com wrote:
 On 11 Feb 2013, at 7:01 PM, Jim S j...@qlf.com wrote:
 Jonathan
 
 I am currently using that as my base for getting this working.  Here is what 
 I have so far:
 
 routers = dict(
 # base router
 BASE=dict(domains = {www.website1.com:mustangs,
 www.website2.com:icysa, }))
 
 But, anytime I to either URL, I get the web2py welcome app.
 
 Also, I've saved the file as routes.py.
 
 And restarted, right?
 
 Try turning on logging for routes and see what you get. You might also 
 examine request.env, and make sure that the target domain is showing up 
 properly.
 
 
 -Jim
 
 On Monday, February 11, 2013 6:32:41 PM UTC-6, Jonathan Lundell wrote:
 On 11 Feb 2013, at 3:36 PM, Jim S j...@qlf.com wrote:
 I'm trying to route traffic that comes in on a specific URL to a specifc 
 app.
 
 Example:
 
 www.host1.com should route to the welcome app
 
 www.host2.com should route to mySpecific app
 
 I realize this is probably trivial, but I'm really struggling with it.  
 Hoping to do it with routes.py and not through wsgi stuff.  Please feel 
 free to set me straight if that is not advisable.
 
 
 Look at the domain-routing provision in the parametric router. Documentation 
 in the book, and in router.example.py.
 
 -- 
  
 
 
 
 
 -- 
  



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-11 Thread newbie
Hi,
I have a table x, with fields name,place,timezone offset.And another 
table y which references to table x and has an additional 
field 'timezone',which displays the timezone of the server its fetching the 
values from.I want to convert the timezone of the server,to the timezone of 
the local user,by using the offset of  from table x,Kindly suggest a way to 
show the converted time in a grid,such that we don't have to convert for 
all the records in the table y.Only the shown page records should be 
converted .Converting all the records might slow the process.So,one page 
will have 20 records,all the records its displaying should be converted to 
user's local timezone.When the user, paginates to another page,those 20 set 
of records shuld be converted that moment and shown.Is it 
possible.Kindly tell a way if this can be achieved.

-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to use a text file instead of a db?

2013-02-11 Thread Rufus

And if you don't need the layout (by returning a dict), just return the 
file contents:

def showfile():
 return (open(filename.ext,r).read())



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-11 Thread newbie

On Tuesday, 12 February 2013 11:06:00 UTC+5:30, newbie wrote: 

 Hi,
 I have a table x, with fields name,place,timezone_offset.And another 
 table y ,having  field 'servertime',which stores the current time of the 
 server its fetching the values from.
  
  db.define_table('x',Field('name'),Field('place'),Field('timezone_offset'
 )) 
 db.define_table('y',Field('name'),Field('servertime'))  

 
User will set the timezone offset in table x, for a particular name. There 
is one thread continuously running in background in the server which will 
save the servertime as local time using datetime.datetime.now() in table y 
for the name.
 
And finally this data displayed by using SQLFORM.grid on the UI.
 
Problem facing:
We have to convert the local time saved for the name field as per saved 
timezone_offset in x table and display on the grid without modifying 
anything on database level.
It means suppose for name ='Alex'  timezone_offset was being saved as -5 in 
x table and suppose server running on different timezone lets say on +5.30 
so for name Alex server will save the servertime in +5.30 format as it is 
the local time for the server but when it will be displayed on the 
grid servertime should first get converted to Alex timezone_offset which is 
set as -5 and then display on the grid.
 
Can anyone please suggest me how can I achieved in web2py? Is there any way 
to achieve it using SQLFORM.grid()?
 
Thanks.
 
 
 

   


-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Converting Field of a SQLFORM.grid to local timezone of a user.....

2013-02-11 Thread Bruno Rocha
I am on mobile now and I cant ellaborate a good code example, but I can
give you a hint.

db.table.datefield.represent = lambda value, row :
value.strftime(%Y/%m/%d)

grid = SQLFORM.grid(db.table)

so grid will use the represent callback to display the data.

following this example you can do

def set_timezone(value, row):
 return value. #do the calculation

db.table.field.represent = set_timezone
Em 12/02/2013 04:44, newbie nehadu...@gmail.com escreveu:


 On Tuesday, 12 February 2013 11:06:00 UTC+5:30, newbie wrote:

 Hi,
 I have a table x, with fields name,place,timezone_offset.And another
 table y ,having  field 'servertime',which **stores the current time of
 the server its fetching the values from.

  db.define_table('x',Field('**name'),Field('place'),Field('**
 timezone_offset'))
 db.define_table('y',Field('**name'),Field('ser**vertime'))


 User will set the timezone offset in table x, for a particular name. There
 is one thread continuously running in background in the server which will
 save the servertime as local time using datetime.datetime.now() in table y
 for the name.

 And finally this data displayed by using SQLFORM.grid on the UI.

 Problem facing:
 We have to convert the local time saved for the name field as per saved
 timezone_offset in x table and display on the grid without modifying
 anything on database level.
 It means suppose for name ='Alex'  timezone_offset was being saved as -5
 in x table and suppose server running on different timezone lets say on
 +5.30 so for name Alex server will save the servertime in +5.30 format as
 it is the local time for the server but when it will be displayed on the
 grid servertime should first get converted to Alex timezone_offset which is
 set as -5 and then display on the grid.

 Can anyone please suggest me how can I achieved in web2py? Is there any
 way to achieve it using SQLFORM.grid()?

 Thanks.






  --

 ---
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Server konfigurations basics redirects

2013-02-11 Thread Emilius Omeen
my english not so good, but maybe I suggest way to solve 

http://web2py.com/books/default/chapter/29/04#URL-rewrite

So you can now have language-specific static files, including images, if 
you need to. Domain mapping is supported as well:

routers = dict(
  BASE  = dict(
  domains = {
  'domain1.com' : 'app1',
  'domain2.com' : 'app2',
  }
  ),
)


about stipping try to use #  path_prefix: a path fragment that is prefixed 
to all outgoing URLs and stripped from all incoming URLs
this information from ../web2py/router.example.py


понедельник, 11 февраля 2013 г., 17:41:40 UTC+4 пользователь BlueShadow 
написал:

 OK the routes.py option sounds pretty promissing. still I will have a 
 problem when I start my second app. So what do I do if I got two 
 domainnames?

 And I would like to hide the application name if it is possible.

 So www.dname1.com= ip/App1/
 and www.dname2.com= ip/App2/



-- 

--- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.