[web2py] Upload from git repro - GitCommandError

2012-08-25 Thread Martin Weissenboeck
I have found, that the url to upload a packed application can be a git
repo and I tried it with
https://github.com/niphlod/w2p_scheduler_tests.git

The result:
type 'exceptions.NameError' global name 'GitCommandError' is not defined

Regards, Martin

-- 





Re: [web2py] Re: Bootstrap replacement for div class=flash?

2012-08-25 Thread Alec Taylor
On Sat, Aug 25, 2012 at 2:33 PM, Massimo Di Pierro
massimo.dipie...@gmail.com wrote:
 As I said. I always liked this but some users did not and complained about
 it. Yet times have changed.
 For web2py 2.0 we have to freeze all layout changes because they take too
 long to be tested.

 For example I had to revert your patch using bootstrap 2.0 because  some
 users have reported problems.

 I'd be happy to consider this for web2py 2.1 and I would support it.

Excellent

 massimo

 On Friday, 24 August 2012 22:52:46 UTC-5, Alec Taylor wrote:

 I remember Massimo saying a little while ago that someone had suggest
 modifying the alert flash (response.flash) display a while back—before
 bootstrap was used in web2py—and that it wasn't well received by the
 community.

 Now with bootstrap I recommend we add in stackoverflow style alerts.

 {{if response.flash:}}
 header
 div class=alert alert-block fade in
 button type=button class=close
 data-dismiss=alerttimes;/button
 p{{=response.flash}}/p
 /div
 /header
 {{pass}}


 Thoughts?

 --




-- 





[web2py] Re: Upload from git repro - GitCommandError

2012-08-25 Thread Martin Weissenboeck
Sorry, I wanted to write:

I have found that a packed application can be a git repo and I tried it
with
https://github.com/niphlod/w2p_scheduler_tests.git

The result:
type 'exceptions.NameError' global name 'GitCommandError' is not defined



2012/8/25 Martin Weissenboeck mweis...@gmail.com

 I have found, that the url to upload a packed application can be a git
 repo and I tried it with
 https://github.com/niphlod/w2p_scheduler_tests.git

 The result:
 type 'exceptions.NameError' global name 'GitCommandError' is not defined

 Regards, Martin




-- 





Re: [web2py] Re: About the Scheduler

2012-08-25 Thread Martin Weissenboeck
Thank you very much these details.

2012/8/24 Niphlod niph...@gmail.com


- Then I have tried to add a scheduler to an existing application.
The worker shows it's heartbeat, but does not pick up any task, What could
be wrong?

 Depends on many factors...let's start to say: how did you add the tasks ?


- What is the best way to start both (scheduler and other
application) in Linux and in Windows?
python web2py.py myapp -K myscheduler is the wrong way

 I have added a new record using the admin application.
In the meantime I have written a function to insert a new task - same
result, the worker does not pick it up.

Scheduler is meant to work as a separate process. Ideally you'd have to
 start the webserver in the usual way (web2py.py -a 'yourpass') and the
 scheduler in a separate terminal/dos shell (web2py.py -K myapp) . Trunk
 permits to have ~the same behaviour with web2py.py -a 'yourpass' -K myapp
 -X: this will start the webserver and in a separate process the scheduler.


The -X sounds good! I have tried it (Windows 7-environment). Should there
be a message like
Currenty running 1 scheduler processes ? This message does not appear
with -X.


 BTW: at https://github.com/niphlod/w2p_scheduler_tests there is a
 complete demo app on scheduler, how it works and how to use it.

 That is very good - sorry, I did not find it before.
I have tried to load this application as git repo (can be a git repo) but
I got:
type 'exceptions.NameError' global name 'GitCommandError' is not defined

I have posted this in another thread.

Regards Martin

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread apps in tables




 1) The document itself if it needs to be schema free can go in a mongodb 
 and there is no need for the DAL apis.


 Let us go schema-free (mongodb), what will be the structure of the 
application ?

 controller , view , (no model) ?

sequence of screens ?

-- 





[web2py] SQLFORM.grid redirects and access

2012-08-25 Thread lyn2py
I have 2 SQLFORM.grids, they are:

##MODELS
db.define_table('company', #each staff can only see the customers under 
their account
Field('company_name', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('description','text'),
format='%(company_name)s'
)

db.define_table('employees', #each customer has their key contacts
Field('company_id','reference company',writable=False,label='Company 
Name'), 
Field('first_name', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('last_name', 'string',length=255,requires=IS_NOT_EMPTY()),
Field('role', 'string',length=255,requires=IS_NOT_EMPTY()),
)

##CONTROLLER
def company():
grid=SQLFORM.grid(db.company.created_by==auth.user_id,links = [lambda 
row: A('Add Employee',,_href=URL(default,employees,args='new')))
return locals()

def employees():
grid=SQLFORM.grid(db.employees.created_by==auth.user_id,links = [lambda 
row: A('View Company Details',_href=URL(default,company,args=row.
company_id)))
return locals()

The problem I have is, When I click on the LINK (either the *Add Employee*or 
the 
*View Company Details* links), I am told Not Authorized.
I assume it has to do with user_signature.

How can I use SQLFORM.grid with user-defined links and still keep 
user_signature=True?

If I am using it wrongly or misinterpret its correct use, please correct me.

Thank you!

-- 





Re: [web2py] Re: About the Scheduler

2012-08-25 Thread Niphlod


On Saturday, August 25, 2012 10:59:44 AM UTC+2, mweissen wrote:

 I have added a new record using the admin application.
 In the meantime I have written a function to insert a new task - same 
 result, the worker does not pick it up.


Please attach the csv for the scheduler_task table, in order to identify 
the problem
 


 The -X sounds good! I have tried it (Windows 7-environment). Should 
 there be a message like 
 Currenty running 1 scheduler processes ? This message does not appear 
 with -X.


With current trunk, the message is displayed if you started with web2py.py 
-K myapp -X
 

 That is very good - sorry, I did not find it before.
 I have tried to load this application as git repo (can be a git repo) 
 but I got: 
 type 'exceptions.NameError' global name 'GitCommandError' is not defined


I didn't follow the new features of being able to install directly from git 
but you can download the app as a zip and place it under the applications/ 
directory

-- 





[web2py] Re: Upload from git repro - GitCommandError

2012-08-25 Thread Niphlod
Yes, you'd need the python-git module installed. I just sent a patch to 
Massimo to let the user know this without raising a ticket. 

On Saturday, August 25, 2012 10:54:19 AM UTC+2, mweissen wrote:

 Sorry, I wanted to write:

 I have found that a packed application can be a git repo and I tried it 
 with 
 https://github.com/niphlod/w2p_scheduler_tests.git

 The result:
 type 'exceptions.NameError' global name 'GitCommandError' is not defined



 2012/8/25 Martin Weissenboeck mwei...@gmail.com javascript:

 I have found, that the url to upload a packed application can be a git 
 repo and I tried it with 
 https://github.com/niphlod/w2p_scheduler_tests.git

 The result:
 type 'exceptions.NameError' global name 'GitCommandError' is not defined

 Regards, Martin





-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread Massimo Di Pierro
This is what is missing. A good coding example...

You may still use models in the web2py sense of code that gets executed 
before every action to define for example Auth and other things. appadmin 
would become useless. SQLFORM only you force a schema.

Massimo

On Saturday, 25 August 2012 05:14:04 UTC-5, apps in tables wrote:





 1) The document itself if it needs to be schema free can go in a mongodb 
 and there is no need for the DAL apis.


 Let us go schema-free (mongodb), what will be the structure of the 
 application ?

  controller , view , (no model) ?

 sequence of screens ?


-- 





[web2py] Re: SQLFORM.grid redirects and access

2012-08-25 Thread Massimo Di Pierro
You have two options:

1) decorate your functions with @auth.requires_login() and user_signature = 
True (default)
2) leave the functions as they are and user_signature = False (no 
protection)

You cannot have a per user signature and at same time not require a logged 
in user.



On Saturday, 25 August 2012 06:53:11 UTC-5, lyn2py wrote:

 I have 2 SQLFORM.grids, they are:

 ##MODELS
 db.define_table('company', #each staff can only see the customers under 
 their account
 Field('company_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('description','text'),
 format='%(company_name)s'
 )

 db.define_table('employees', #each customer has their key contacts
 Field('company_id','reference company',writable=False,label='Company 
 Name'), 
 Field('first_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('last_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('role', 'string',length=255,requires=IS_NOT_EMPTY()),
 )

 ##CONTROLLER
 def company():
 grid=SQLFORM.grid(db.company.created_by==auth.user_id,links = [lambda 
 row: A('Add Employee',,_href=URL(default,employees,args='new')))
 return locals()

 def employees():
 grid=SQLFORM.grid(db.employees.created_by==auth.user_id,links = 
 [lambda row: A('View Company 
 Details',_href=URL(default,company,args=row.company_id)))
 return locals()

 The problem I have is, When I click on the LINK (either the *Add Employee*or 
 the 
 *View Company Details* links), I am told Not Authorized.
 I assume it has to do with user_signature.

 How can I use SQLFORM.grid with user-defined links and still keep 
 user_signature=True?

 If I am using it wrongly or misinterpret its correct use, please correct 
 me.

 Thank you!


-- 





[web2py] SQLFORM id

2012-08-25 Thread pylix
I'm having trouble getting the server to access the id field upon 
submission of my SQLFORM
I did not define my own id field in the model, i have no issue with the 
auto-created one except that
I can't figure out how to store the id in a variable for view use. 

all other fields are accessible using forms.vars i.e form.vars.name, 
form.vars.email, etc..
but form.vars.id always ends up as None.

The id field values are recorded and can be queried
or viewed using appadmin database administration
but, what I'm trying to do is use the Id# in a view that
i want to display after form submission.

is there a special way to get the id# that the
record being inserted to database would be
if it validates?

-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread Anthony
Can you show your code? It should be in form.vars.id after submission.

Anthony

On Saturday, August 25, 2012 9:16:42 AM UTC-4, pylix wrote:

 I'm having trouble getting the server to access the id field upon 
 submission of my SQLFORM
 I did not define my own id field in the model, i have no issue with the 
 auto-created one except that
 I can't figure out how to store the id in a variable for view use. 

 all other fields are accessible using forms.vars i.e form.vars.name, 
 form.vars.email, etc..
 but form.vars.id always ends up as None.

 The id field values are recorded and can be queried
 or viewed using appadmin database administration
 but, what I'm trying to do is use the Id# in a view that
 i want to display after form submission.

 is there a special way to get the id# that the
 record being inserted to database would be
 if it validates?


-- 





[web2py] Re: get rid of 'verify password' in register?

2012-08-25 Thread Anthony
Are you saying you don't want the verify password field on the register 
form (i.e., requiring users to enter the password twice when registering)? 
If so, just do this after defining auth:

auth.settings.register_verify_password = False

Anthony

On Saturday, August 25, 2012 12:02:08 AM UTC-4, Alec Taylor wrote:

 Oh right, I had to actually edit the gluon\tools.py file. Thought it was a 
 variable I could modify from db.py.

 On Saturday, August 25, 2012 1:58:56 PM UTC+10, Alec Taylor wrote:

 Was this feature taken out?

 I'd really like to use it :)

 On Tuesday, August 23, 2011 10:14:36 PM UTC+10, Massimo Di Pierro wrote:

 oops. my mistake. 

 On Aug 22, 11:04 pm, Anthony abasta...@gmail.com wrote: 
  Well, you had to wait a whole 20 minutes, but Massimo is on the case:
 http://code.google.com/p/web2py/source/detail?r=2c1f4c7f4f8e7e286d561... 

  . 
  
  Maybe it should be called settings.register_verify_password, since 
 it's on 
  the registration form, not the login form. 
  
  Anthony 
  
  
  
  
  
  
  
  On Monday, August 22, 2011 11:37:10 PM UTC-4, rochacbruno wrote: 
   I am a bit lazy to hack my own register form, 
  
   is there a simple way to remove the need of Verify Password  from 
   auth/register? 
  
   I want the user only to use [name, email, password, submit], I know 
 how to 
   do that hacking a bit or using custom forms. But, is there an API 
 way? 
  
   ( auth.settings.verify_password = False ???  ) 
  
   -- 
   Bruno Rocha 
   [ About me:http://zerp.ly/rochacbruno] 
   [ Aprenda a programar:http://CursoDePython.com.br] 
   [ O seu aliado nos cuidados com os animais:
 http://AnimalSystem.com.br] 
   [ Consultoria em desenvolvimento web:http://www.blouweb.com]



-- 





[web2py] Re: SQLFORM.grid redirects and access

2012-08-25 Thread lyn2py
Hi Massimo,

I picked Option(1). 
They both have @auth.requires_membership('Admin') and user_signature=True 
(the default setting)
I used a logged-in account that has access to both functions.

Both pages can be accessed individually, but cannot be accessed when either 
link is used.

I am using the latest trunk
Version 2.00.0 (2012-08-24 23:47:44) dev



On Saturday, August 25, 2012 9:04:13 PM UTC+8, Massimo Di Pierro wrote:

 You have two options:

 1) decorate your functions with @auth.requires_login() and user_signature 
 = True (default)
 2) leave the functions as they are and user_signature = False (no 
 protection)

 You cannot have a per user signature and at same time not require a logged 
 in user.



 On Saturday, 25 August 2012 06:53:11 UTC-5, lyn2py wrote:

 I have 2 SQLFORM.grids, they are:

 ##MODELS
 db.define_table('company', #each staff can only see the customers under 
 their account
 Field('company_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('description','text'),
 format='%(company_name)s'
 )

 db.define_table('employees', #each customer has their key contacts
 Field('company_id','reference company',writable=False,label='Company 
 Name'), 
 Field('first_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('last_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('role', 'string',length=255,requires=IS_NOT_EMPTY()),
 )

 ##CONTROLLER
 def company():
 grid=SQLFORM.grid(db.company.created_by==auth.user_id,links = 
 [lambda row: A('Add Employee',,_href=URL(default,employees,args='new')))
 return locals()

 def employees():
 grid=SQLFORM.grid(db.employees.created_by==auth.user_id,links = 
 [lambda row: A('View Company 
 Details',_href=URL(default,company,args=row.company_id)))
 return locals()

 The problem I have is, When I click on the LINK (either the *Add Employee
 * or the *View Company Details* links), I am told Not Authorized.
 I assume it has to do with user_signature.

 How can I use SQLFORM.grid with user-defined links and still keep 
 user_signature=True?

 If I am using it wrongly or misinterpret its correct use, please correct 
 me.

 Thank you!



-- 





Re: [web2py] Re: get rid of 'verify password' in register?

2012-08-25 Thread Alec Taylor
Hmm, that worked this time... not sure what happened last-time. Maybe
I had put the code in the wrong section of the file?

On Sat, Aug 25, 2012 at 11:48 PM, Anthony abasta...@gmail.com wrote:
 Are you saying you don't want the verify password field on the register form
 (i.e., requiring users to enter the password twice when registering)? If so,
 just do this after defining auth:

 auth.settings.register_verify_password = False

 Anthony


 On Saturday, August 25, 2012 12:02:08 AM UTC-4, Alec Taylor wrote:

 Oh right, I had to actually edit the gluon\tools.py file. Thought it was a
 variable I could modify from db.py.

 On Saturday, August 25, 2012 1:58:56 PM UTC+10, Alec Taylor wrote:

 Was this feature taken out?

 I'd really like to use it :)

 On Tuesday, August 23, 2011 10:14:36 PM UTC+10, Massimo Di Pierro wrote:

 oops. my mistake.

 On Aug 22, 11:04 pm, Anthony abasta...@gmail.com wrote:
  Well, you had to wait a whole 20 minutes, but Massimo is on the
  case:http://code.google.com/p/web2py/source/detail?r=2c1f4c7f4f8e7e286d561...
  .
 
  Maybe it should be called settings.register_verify_password, since
  it's on
  the registration form, not the login form.
 
  Anthony
 
 
 
 
 
 
 
  On Monday, August 22, 2011 11:37:10 PM UTC-4, rochacbruno wrote:
   I am a bit lazy to hack my own register form,
 
   is there a simple way to remove the need of Verify Password  from
   auth/register?
 
   I want the user only to use [name, email, password, submit], I know
   how to
   do that hacking a bit or using custom forms. But, is there an API
   way?
 
   ( auth.settings.verify_password = False ???  )
 
   --
   Bruno Rocha
   [ About me:http://zerp.ly/rochacbruno]
   [ Aprenda a programar:http://CursoDePython.com.br]
   [ O seu aliado nos cuidados com os
   animais:http://AnimalSystem.com.br]
   [ Consultoria em desenvolvimento web:http://www.blouweb.com]

 --




-- 





[web2py] Re: SQLFORM.grid redirects and access

2012-08-25 Thread lyn2py
Figured it out.

I need to put user_signature=True in all the links as well. 

Sorry for the noise.

On Saturday, August 25, 2012 9:52:17 PM UTC+8, lyn2py wrote:

 Hi Massimo,

 I picked Option(1). 
 They both have @auth.requires_membership('Admin') and user_signature=True 
 (the default setting)
 I used a logged-in account that has access to both functions.

 Both pages can be accessed individually, but cannot be accessed when 
 either link is used.

 I am using the latest trunk
 Version 2.00.0 (2012-08-24 23:47:44) dev



 On Saturday, August 25, 2012 9:04:13 PM UTC+8, Massimo Di Pierro wrote:

 You have two options:

 1) decorate your functions with @auth.requires_login() and user_signature 
 = True (default)
 2) leave the functions as they are and user_signature = False (no 
 protection)

 You cannot have a per user signature and at same time not require a 
 logged in user.



 On Saturday, 25 August 2012 06:53:11 UTC-5, lyn2py wrote:

 I have 2 SQLFORM.grids, they are:

 ##MODELS
 db.define_table('company', #each staff can only see the customers under 
 their account
 Field('company_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('description','text'),
 format='%(company_name)s'
 )

 db.define_table('employees', #each customer has their key contacts
 Field('company_id','reference company',writable=False,label='Company 
 Name'), 
 Field('first_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('last_name', 'string',length=255,requires=IS_NOT_EMPTY()),
 Field('role', 'string',length=255,requires=IS_NOT_EMPTY()),
 )

 ##CONTROLLER
 def company():
 grid=SQLFORM.grid(db.company.created_by==auth.user_id,links = 
 [lambda row: A('Add Employee',,_href=URL(default,employees,args='new')))
 return locals()

 def employees():
 grid=SQLFORM.grid(db.employees.created_by==auth.user_id,links = 
 [lambda row: A('View Company 
 Details',_href=URL(default,company,args=row.company_id)))
 return locals()

 The problem I have is, When I click on the LINK (either the *Add 
 Employee* or the *View Company Details* links), I am told Not 
 Authorized.
 I assume it has to do with user_signature.

 How can I use SQLFORM.grid with user-defined links and still keep 
 user_signature=True?

 If I am using it wrongly or misinterpret its correct use, please correct 
 me.

 Thank you!



-- 





[web2py] Field.Lazy attaching unbound Class method

2012-08-25 Thread Marek Mollin
Hello,

I have a problem with a construct like that:
db.define_table('test',
Field('name'),
)


class Test(object):
def get(row):
return row.name
def get_hello(row, greeting):
return '%s %s' % (greeting, row.name)


db.test.get = Field.Lazy(Test.get)
db.test.get_hello = Field.Lazy(Test.get_hello)

Why it would not work ?
It works perfect if its a standard function. But if its unbound method I 
get TypeError expected at least 1.

I am trying to do that in order to better organize models, I do not want to 
go as far as Bruno's modelless aproach as performance is not the issue but 
overtime they become messy. (Also I know that I can just make seperate 
file, but then I have to add number to the file and again it becomes very 
unclean).

The whole deal is to move at least some of the logic to those Lazy fields 
(its a pain to have fat controllers).

-- 





[web2py] Re: custom built login form

2012-08-25 Thread shartha
Thanks Anthony, I didn't know you could use jQuery selectors for the second 
argument. One more question:
Is it possible to generate the *remember me checkbox* using the *
form.custom.widget*, or I should create my own checkbox?

On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:

 Hello, 
 Quick question:
 Instead of {{=auth.login()}}, I am using the following to be able to 
 customize my login form. However the resulting form does not work and I 
 cannot login with the same username/password that enable me to login if I 
 had used {{=auth.login()}} -- I get the flash error: Invalid Login.

 Could someone please tell me what's possibly going wrong? Thanks!

 {{form=auth.login()}}
 {{=form.custom.begin}} 
 Username:
 {{=form.custom.widget.username}}
 /br
 Password:
 {{=form.custom.widget.password}}
 {{=form.custom.submit}} 
 {{=form.custom.end}} 


-- 





[web2py] Re: custom built login form

2012-08-25 Thread Anthony
On Saturday, August 25, 2012 11:33:57 AM UTC-4, shartha wrote:

 Thanks Anthony, I didn't know you could use jQuery selectors for the 
 second argument. One more question:
 Is it possible to generate the *remember me checkbox* using the *
 form.custom.widget*, or I should create my own checkbox?


No, it's added to the form DOM after the SQLFORM is created, so it's not 
available in form.custom.widget. However, you can access the div that 
contains the checkbox and label via:

form.element('#auth_user_remember').parent

or the entire table row containing the widget via:

f.element('#auth_user_remember__row')

Anthony

-- 





[web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Anthony
Perhaps you want to use static methods:

class Test(object):
@staticmethod
def get(row):
return row.name

Anthony

On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method I 
 get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not want 
 to go as far as Bruno's modelless aproach as performance is not the issue 
 but overtime they become messy. (Also I know that I can just make seperate 
 file, but then I have to add number to the file and again it becomes very 
 unclean).

 The whole deal is to move at least some of the logic to those Lazy fields 
 (its a pain to have fat controllers).


-- 





[web2py] Formulario personalizado

2012-08-25 Thread Miguel
Hola,

Estoy haciendo pruebas con formularios y me ha surgido una duda, quisiera 
crear un formulario de creación (SQLFORM, CRUD.create o similar) de una 
tabla.

En esa tabla tengo una relación con otra tabla, al crear el formulario de 
la tabla completa me aparece la relación mediante un combo de selección con 
los valores de la otra tabla.

Mi pregunta es si ese formulario lo puedo restringir para que solo 
aparezcan en el combo de selección determinados valores.

Gracias
Miguel

-- 





[web2py] DAL not returning results on temp table query

2012-08-25 Thread Yarin
I'm trying to execute some SQL from the DAL that relies on a temp table:

CREATE TEMPORARY TABLE tmp LIKE people;

 INSERT INTO tmp SELECT * FROM people;
 INSERT INTO tmp SELECT * FROM people;
 SELECT * FROM tmp;


This code works fine in a SQL panel, but fails when used in the DAL:

def test():


 db_test = DAL('mysql://root:root@localhost/test')
 
 sql = CREATE TEMPORARY TABLE tmp LIKE people;
 INSERT INTO tmp SELECT * FROM people;
 INSERT INTO tmp SELECT * FROM people;
 SELECT * FROM tmp;
 
 results = db_test.executesql(sql)


Results always returns None. No idea why or how to proceed.

-- 





Re: [web2py] Field.Lazy attaching unbound Class method

2012-08-25 Thread Jonathan Lundell
On 25 Aug 2012, at 8:33 AM, Marek Mollin rog...@gmail.com wrote:
 Hello,
 
 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )
 
 
 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)
 
 
 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)
 
 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method I get 
 TypeError expected at least 1.
 
 I am trying to do that in order to better organize models, I do not want to 
 go as far as Bruno's modelless aproach as performance is not the issue but 
 overtime they become messy. (Also I know that I can just make seperate file, 
 but then I have to add number to the file and again it becomes very unclean).
 
 The whole deal is to move at least some of the logic to those Lazy fields 
 (its a pain to have fat controllers).
 
 

At the very least you'll need to declare get and get_hello to be class (or 
static) methods. Remember that 'self' in Python is an arbitrary name; your 
class would be syntactically identical if you had written it:

class Test(object):
def get(self):
return self.name
def get_hello(self, greeting):
return '%s %s' % (greeting, self.name)

...and you wouldn't expect that to work as you wanted.

-- 





[web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Marek Mollin
Still not working.
When I add static I can do:

 Test.get(db.test[1])
 'testobject'

This is fine.
But I cant do db.test[1].get() as it gives me TypeError - expected at least 
1 argument.
I thought that if something is defined as Field.Lazy that function 
automatically gets row as first argument. I mean that's how it works 
normally with regular functions.


W dniu sobota, 25 sierpnia 2012 17:47:14 UTC+2 użytkownik Anthony napisał:

 Perhaps you want to use static methods:

 class Test(object):
 @staticmethod
 def get(row):
 return row.name

 Anthony

 On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method I 
 get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not want 
 to go as far as Bruno's modelless aproach as performance is not the issue 
 but overtime they become messy. (Also I know that I can just make seperate 
 file, but then I have to add number to the file and again it becomes very 
 unclean).

 The whole deal is to move at least some of the logic to those Lazy fields 
 (its a pain to have fat controllers).



-- 





Re: [web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Marin Pranjić
You don't have to call .get()
It will be called internally with a row as an argument.

And you should be using row.tablename.fieldname (instead just row.fieldname)

Marin

On Sat, Aug 25, 2012 at 6:20 PM, Marek Mollin rog...@gmail.com wrote:

 Still not working.
 When I add static I can do:

  Test.get(db.test[1])
  'testobject'

 This is fine.
 But I cant do db.test[1].get() as it gives me TypeError - expected at
 least 1 argument.
 I thought that if something is defined as Field.Lazy that function
 automatically gets row as first argument. I mean that's how it works
 normally with regular functions.


 W dniu sobota, 25 sierpnia 2012 17:47:14 UTC+2 użytkownik Anthony napisał:

 Perhaps you want to use static methods:

 class Test(object):
 @staticmethod
 def get(row):
 return row.name

 Anthony

 On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method I
 get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not want
 to go as far as Bruno's modelless aproach as performance is not the issue
 but overtime they become messy. (Also I know that I can just make seperate
 file, but then I have to add number to the file and again it becomes very
 unclean).

 The whole deal is to move at least some of the logic to those Lazy
 fields (its a pain to have fat controllers).

  --





-- 





Re: [web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Marin Pranjić
Ignore my comment... This is Field.Lazy not .Virtual.
Sorry

On Sat, Aug 25, 2012 at 6:29 PM, Marin Pranjić marin.pran...@gmail.comwrote:

 You don't have to call .get()
 It will be called internally with a row as an argument.

 And you should be using row.tablename.fieldname (instead just
 row.fieldname)

 Marin


 On Sat, Aug 25, 2012 at 6:20 PM, Marek Mollin rog...@gmail.com wrote:

 Still not working.
 When I add static I can do:

  Test.get(db.test[1])
  'testobject'

 This is fine.
 But I cant do db.test[1].get() as it gives me TypeError - expected at
 least 1 argument.
 I thought that if something is defined as Field.Lazy that function
 automatically gets row as first argument. I mean that's how it works
 normally with regular functions.


 W dniu sobota, 25 sierpnia 2012 17:47:14 UTC+2 użytkownik Anthony napisał:

 Perhaps you want to use static methods:

 class Test(object):
 @staticmethod
 def get(row):
 return row.name

 Anthony

 On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method
 I get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not
 want to go as far as Bruno's modelless aproach as performance is not the
 issue but overtime they become messy. (Also I know that I can just make
 seperate file, but then I have to add number to the file and again it
 becomes very unclean).

 The whole deal is to move at least some of the logic to those Lazy
 fields (its a pain to have fat controllers).

  --







-- 





Re: [web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Marek Mollin
I missed the table name alright.
But lazy fields wont be called internally...
so row.tablename.fieldname will return a function rather than value...

W dniu sobota, 25 sierpnia 2012 18:29:00 UTC+2 użytkownik Marin Pranjić 
napisał:

 You don't have to call .get()
 It will be called internally with a row as an argument.

 And you should be using row.tablename.fieldname (instead just 
 row.fieldname)

 Marin

 On Sat, Aug 25, 2012 at 6:20 PM, Marek Mollin rog...@gmail.comjavascript:
  wrote:

 Still not working.
 When I add static I can do:

  Test.get(db.test[1])
  'testobject'

 This is fine.
 But I cant do db.test[1].get() as it gives me TypeError - expected at 
 least 1 argument.
 I thought that if something is defined as Field.Lazy that function 
 automatically gets row as first argument. I mean that's how it works 
 normally with regular functions.


 W dniu sobota, 25 sierpnia 2012 17:47:14 UTC+2 użytkownik Anthony napisał:

 Perhaps you want to use static methods:

 class Test(object):
 @staticmethod
 def get(row):
 return row.name

 Anthony

 On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method 
 I get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not 
 want to go as far as Bruno's modelless aproach as performance is not the 
 issue but overtime they become messy. (Also I know that I can just make 
 seperate file, but then I have to add number to the file and again it 
 becomes very unclean).

 The whole deal is to move at least some of the logic to those Lazy 
 fields (its a pain to have fat controllers).

  -- 
  
  
  




-- 





Re: [web2py] Major speed improvement need testers

2012-08-25 Thread Jonathan Lundell
On 23 Aug 2012, at 7:25 AM, Massimo Di Pierro massimo.dipie...@gmail.com 
wrote:
 So now in trunk you can do:
 
 db = DAL(lazy_tables=True)
 db.define_table('person',Field('name'),Field('age','integer'),
on_define=lambda table: [
table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''),

 table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30),
   ])
 
 and the attributes will be set lazily. This is a good idea! Thanks Jonathan.
 

Clear something up for me, please. I was a little confused before about how 
this was implemented, but I've read the code and it looks like what I proposed. 
What I'm not following is the role of set_attributes. Is it simply to 
facilitate the lambda? Is this equivalent?

def on_define(table):
 table.name.requires = IS_NOT_EMPTY()
 table.name.default = ''
 table.age.requires = IS_INT_IN_RANGE(0,120)
 table.age.default = 30

db = DAL(lazy_tables=True)
db.define_table('person', Field('name'), Field('age','integer'), 
on_define=on_define)

-- 





Re: [web2py] Re: Field.Lazy attaching unbound Class method

2012-08-25 Thread Marin Pranjić
Found it...


You should not use 'get' as a fieldname.

if you change 'db.test.get' to 'db.test._get' or something else, it will
work.

or you can use:

db.test[1]['get']() instead of db.test[1].get()

Marin

On Sat, Aug 25, 2012 at 6:35 PM, Marek Mollin rog...@gmail.com wrote:

 I missed the table name alright.
 But lazy fields wont be called internally...
 so row.tablename.fieldname will return a function rather than value...

 W dniu sobota, 25 sierpnia 2012 18:29:00 UTC+2 użytkownik Marin Pranjić
 napisał:

 You don't have to call .get()
 It will be called internally with a row as an argument.

 And you should be using row.tablename.fieldname (instead just
 row.fieldname)

 Marin

 On Sat, Aug 25, 2012 at 6:20 PM, Marek Mollin rog...@gmail.com wrote:

 Still not working.
 When I add static I can do:

  Test.get(db.test[1])
  'testobject'

 This is fine.
 But I cant do db.test[1].get() as it gives me TypeError - expected at
 least 1 argument.
 I thought that if something is defined as Field.Lazy that function
 automatically gets row as first argument. I mean that's how it works
 normally with regular functions.


 W dniu sobota, 25 sierpnia 2012 17:47:14 UTC+2 użytkownik Anthony
 napisał:

 Perhaps you want to use static methods:

 class Test(object):
 @staticmethod
 def get(row):
 return row.name

 Anthony

 On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:

 Hello,

 I have a problem with a construct like that:
 db.define_table('test',
 Field('name'),
 )


 class Test(object):
 def get(row):
 return row.name
 def get_hello(row, greeting):
 return '%s %s' % (greeting, row.name)


 db.test.get = Field.Lazy(Test.get)
 db.test.get_hello = Field.Lazy(Test.get_hello)

 Why it would not work ?
 It works perfect if its a standard function. But if its unbound method
 I get TypeError expected at least 1.

 I am trying to do that in order to better organize models, I do not
 want to go as far as Bruno's modelless aproach as performance is not the
 issue but overtime they become messy. (Also I know that I can just make
 seperate file, but then I have to add number to the file and again it
 becomes very unclean).

 The whole deal is to move at least some of the logic to those Lazy
 fields (its a pain to have fat controllers).

  --





  --





-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread apps in tables

Do you mean that this will be the next web2py example (appliance)?

-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread Niphlod
I lost the meaning of your pointsorry.

DAL is meant to be a universal glue to let the users work with some nice 
syntax and be able to be database independant. Used within web2py, it 
speeds up form creation and data retrieval for many dbs (including NoSQL 
ones).
YesSQL (please bear with this term) dbs alltogether (someone more, 
someone less) pack the exact same features, although hidden by some 
differencies in the T-SQL language, that DAL eliminates (i.e. DAL gives you 
the same interface for the same features in all YesSQL db).

Every Nosql, instead, is created/coded/implemented with very different 
objectives (it is what it makes them a useful tool, or they'd never gonna 
make it against the well known YesSQL alternatives). Those different 
objectives effectively null the possibility to have a common API to all 
of them while mantaining a full access to every different feature.

Nonetheless, DAL abstracts in the better way possible the common features 
you'd want in a MVC application: you HAVE to have a model (even using 
NoSQL) if you want to expose the same data for n users and a model is 
required for form generation. The MVC pattern allows you to have a common 
denominator and code fast. You can still work with no model, but then DAL 
loses some of its commodities.

You decided that NoSQL is the technology fit for your application. Well, 
DAL allows you to query a NoSQL db given that you know in advance what you 
want (again: your model). 
For the parts where a model is not known in advance, you can use the 
underlying NoSQL adapter of your choice to accomplish everything you want.

What is your requirement then ? What are you missing ?

On Saturday, August 25, 2012 7:38:03 PM UTC+2, apps in tables wrote:


 Do you mean that this will be the next web2py example (appliance)?


-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread pylix
the problem i found after debugging is this... 
here's the some code in the model 

def build_email(form):
html_email = 'html%s/html' % BEAUTIFY(form.vars)
mail.send(to=['destinat...@gmail.com'],
reply_to=form.vars.email,
subject='request' + str(form.vars.id), 
message=html_email)
session.id = form.vars.id

def freequote():
form = SQLFORM(db.person)
if form.process(onvalidation=build_email).accepted:
redirect(URL(quotesuccess))
else:
responce.flash = 'errors found'
return dict(form=form)

the problem i see is that before the form is accepted,
id does not exist, while all the other fields can
be accessed with form.vars.field, in the code above
form.vars.id = None so the email subject would
be requestNone.

when the onvalidation function is omitted
and instead the freequote controller directly calls the function after
the form is processed, form.vars.id works as expected

I misinterpreted the purpose of onvalidation
i'd like to send emails after not before forms
are validated so i have no more issues.

but this all leads me to the realization that web2py does
not give a value to the form field of a SQLFORM until the form
is processed, is there a request.vars.id that can
be used before processing?




On Saturday, August 25, 2012 9:43:48 AM UTC-4, Anthony wrote:

 Can you show your code? It should be in form.vars.id after submission.

 Anthony

 On Saturday, August 25, 2012 9:16:42 AM UTC-4, pylix wrote:

 I'm having trouble getting the server to access the id field upon 
 submission of my SQLFORM
 I did not define my own id field in the model, i have no issue with the 
 auto-created one except that
 I can't figure out how to store the id in a variable for view use. 

 all other fields are accessible using forms.vars i.e form.vars.name, 
 form.vars.email, etc..
 but form.vars.id always ends up as None.

 The id field values are recorded and can be queried
 or viewed using appadmin database administration
 but, what I'm trying to do is use the Id# in a view that
 i want to display after form submission.

 is there a special way to get the id# that the
 record being inserted to database would be
 if it validates?



-- 





[web2py] Re: DAL not returning results on temp table query

2012-08-25 Thread Niphlod
I think the DBAPI doesn't support several results set in a single statement.

If you cared to do those one line at a time you'd noticed that:
create temporary table tmp like people does not return results.
insert into tmp select * from people returns the just inserted values
select * from tmp returns your lines.

I think that as long as you have only one statement (and it's the last ) in 
your executesql() wrapped string you'll be fine. If some of your lines 
returns results, then the driver doesn't know what set to actually return.
Anyway splitting those lines in multiple db.executesql()s is working great.

On Saturday, August 25, 2012 5:58:40 PM UTC+2, Yarin wrote:

 I'm trying to execute some SQL from the DAL that relies on a temp table:

 CREATE TEMPORARY TABLE tmp LIKE people;

  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;


 This code works fine in a SQL panel, but fails when used in the DAL:

 def test():


  db_test = DAL('mysql://root:root@localhost/test')
  
  sql = CREATE TEMPORARY TABLE tmp LIKE people;
  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;
  
  results = db_test.executesql(sql)


 Results always returns None. No idea why or how to proceed.


-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread pylix

fixed a typo

On Saturday, August 25, 2012 2:52:17 PM UTC-4, pylix wrote:

 the problem i found after debugging is this... 
 here's the some code in the model 

 def build_email(form):
 html_email = 'html%s/html' % BEAUTIFY(form.vars)
 mail.send(to=['destinat...@gmail.com'],
 reply_to=form.vars.email,
 subject='request' + str(form.vars.id), 
 message=html_email)
 session.id = form.vars.id

 def freequote():
 form = SQLFORM(db.person)
 if form.process(onvalidation=build_email).accepted:
 redirect(URL(quotesuccess))
 else:
 response.flash = 'errors found'
 return dict(form=form)

 the problem i see is that before the form is accepted,
 id does not exist, while all the other fields can
 be accessed with form.vars.field, in the code above
 form.vars.id = None so the email subject would
 be requestNone.

 when the onvalidation function is omitted
 and instead the freequote controller directly calls the function after
 the form is processed, form.vars.id works as expected

 I misinterpreted the purpose of onvalidation
 i'd like to send emails after not before forms
 are validated so i have no more issues.

 but this all leads me to the realization that web2py does
 not give a value to the form field of a SQLFORM until the form
 is processed, is there a request.vars.id that can
 be used before processing?




 On Saturday, August 25, 2012 9:43:48 AM UTC-4, Anthony wrote:

 Can you show your code? It should be in form.vars.id after submission.

 Anthony

 On Saturday, August 25, 2012 9:16:42 AM UTC-4, pylix wrote:

 I'm having trouble getting the server to access the id field upon 
 submission of my SQLFORM
 I did not define my own id field in the model, i have no issue with the 
 auto-created one except that
 I can't figure out how to store the id in a variable for view use. 

 all other fields are accessible using forms.vars i.e form.vars.name, 
 form.vars.email, etc..
 but form.vars.id always ends up as None.

 The id field values are recorded and can be queried
 or viewed using appadmin database administration
 but, what I'm trying to do is use the Id# in a view that
 i want to display after form submission.

 is there a special way to get the id# that the
 record being inserted to database would be
 if it validates?



-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread Niphlod
For creation forms (forms that not update an existing record but insert a 
new one) you do not know the id in advance.
onvalidation is called before the record is inserted, and is meant to 
report any errors that standard validators do not cover.

Your function is called a moment before the record is inserted, and web2py 
does not (yet) know what will be the the id of it. That's because if your 
function fills form.errors:
 a) the record would be discarded
 b) the page will return the form with the corresponding errors

On Saturday, August 25, 2012 8:57:55 PM UTC+2, pylix wrote:


 fixed a typo

 On Saturday, August 25, 2012 2:52:17 PM UTC-4, pylix wrote:

 the problem i found after debugging is this... 
 here's the some code in the model 

 def build_email(form):
 html_email = 'html%s/html' % BEAUTIFY(form.vars)
 mail.send(to=['desti...@gmail.com javascript:'],
 reply_to=form.vars.email,
 subject='request' + str(form.vars.id), 
 message=html_email)
 session.id = form.vars.id

 def freequote():
 form = SQLFORM(db.person)
 if form.process(onvalidation=build_email).accepted:
 redirect(URL(quotesuccess))
 else:
 response.flash = 'errors found'
 return dict(form=form)

 the problem i see is that before the form is accepted,
 id does not exist, while all the other fields can
 be accessed with form.vars.field, in the code above
 form.vars.id = None so the email subject would
 be requestNone.

 when the onvalidation function is omitted
 and instead the freequote controller directly calls the function after
 the form is processed, form.vars.id works as expected

 I misinterpreted the purpose of onvalidation
 i'd like to send emails after not before forms
 are validated so i have no more issues.

 but this all leads me to the realization that web2py does
 not give a value to the form field of a SQLFORM until the form
 is processed, is there a request.vars.id that can
 be used before processing?




 On Saturday, August 25, 2012 9:43:48 AM UTC-4, Anthony wrote:

 Can you show your code? It should be in form.vars.id after submission.

 Anthony

 On Saturday, August 25, 2012 9:16:42 AM UTC-4, pylix wrote:

 I'm having trouble getting the server to access the id field upon 
 submission of my SQLFORM
 I did not define my own id field in the model, i have no issue with the 
 auto-created one except that
 I can't figure out how to store the id in a variable for view use. 

 all other fields are accessible using forms.vars i.e form.vars.name, 
 form.vars.email, etc..
 but form.vars.id always ends up as None.

 The id field values are recorded and can be queried
 or viewed using appadmin database administration
 but, what I'm trying to do is use the Id# in a view that
 i want to display after form submission.

 is there a special way to get the id# that the
 record being inserted to database would be
 if it validates?



-- 





[web2py] Error when assigning form.vars

2012-08-25 Thread SeamusSeamus
When I do this:
form=SQLFORM.factory(
Field('your_email',requires=IS_EMAIL()),
Field('your_phone'),
Field('subject'),
Field('question', 'text', requires=IS_NOT_EMPTY()))
form.vars = dict(subject='Item %s: %s' % (database.id, database.title))
if form.process().accepted:
if mail.send(to='m...@domain.com',
subject='Regarding %s' % form.vars.subject,
message='From %s at %s: %s' % (form.vars.your_email, 
form.vars.your_phone, form.vars.question)):
response.flash='Your message has been sent! We will contact you 
shortly.'
elif form.errors:
form.errors.your_email='Unable to send email'

return dict(equipment=equipment, form=form)


I get this error:

Traceback (most recent call last):
  File /home/james/web2py/gluon/restricted.py, line 205, in restricted
exec ccode in environment
  File /home/james/web2py/applications/equipment/controllers/default.py 
http://127.0.0.1:8000/admin/edit/equipment/controllers/default.py, line 309, 
in module
  File /home/james/web2py/gluon/globals.py, line 173, in lambda
self._caller = lambda f: f()
  File /home/james/web2py/applications/equipment/controllers/default.py 
http://127.0.0.1:8000/admin/edit/equipment/controllers/default.py, line 179, 
in details
if form.process().accepted:
  File /home/james/web2py/gluon/html.py, line 1994, in process
self.validate(**kwargs)
  File /home/james/web2py/gluon/html.py, line 1941, in validate
if self.accepts(**kwargs):
  File /home/james/web2py/gluon/sqlhtml.py, line 1274, in accepts
self.vars.id = self.table.insert(**fields)
AttributeError: 'dict' object has no attribute 'id'



PS: What is the best way to provide a condition in case mail sending fails?

-- 





Re: [web2py] Error when assigning form.vars

2012-08-25 Thread Jonathan Lundell
On 25 Aug 2012, at 12:27 PM, SeamusSeamus morrisjamespatr...@gmail.com wrote:
 When I do this:
 form=SQLFORM.factory(
 Field('your_email',requires=IS_EMAIL()),
 Field('your_phone'),
 Field('subject'),
 Field('question', 'text', requires=IS_NOT_EMPTY()))
 form.vars = dict(subject='Item %s: %s' % (database.id, database.title))

form.vars needs to be Storage, not dict.

 if form.process().accepted:
 if mail.send(to='m...@domain.com',
 subject='Regarding %s' % form.vars.subject,
 message='From %s at %s: %s' % (form.vars.your_email, 
 form.vars.your_phone, form.vars.question)):
 response.flash='Your message has been sent! We will contact you 
 shortly.'
 elif form.errors:
 form.errors.your_email='Unable to send email'
 
 return dict(equipment=equipment, form=form)
 
 
 I get this error:
 
 Traceback (most recent call last):
   File /home/james/web2py/gluon/restricted.py, line 205, in restricted
 exec ccode in environment
   File /home/james/web2py/applications/equipment/controllers/default.py, 
 line 309, in module
   File /home/james/web2py/gluon/globals.py, line 173, in lambda
 self._caller = lambda f: f()
   File /home/james/web2py/applications/equipment/controllers/default.py, 
 line 179, in details
 if form.process().accepted:
   File /home/james/web2py/gluon/html.py, line 1994, in process
 self.validate(**kwargs)
   File /home/james/web2py/gluon/html.py, line 1941, in validate
 if self.accepts(**kwargs):
   File /home/james/web2py/gluon/sqlhtml.py, line 1274, in accepts
 self.vars.id = self.table.insert(**fields)
 AttributeError: 'dict' object has no attribute 'id'
 
 
 PS: What is the best way to provide a condition in case mail sending fails?
 
 -- 
  
  
  


-- 





[web2py] set a javascript variable using web2py helpers

2012-08-25 Thread shartha
Hi, 

Is there any way to set the value of a global javascript variable defined 
in a .js file using web2py helpers?
I have an image in my static/image folder and I want to use the URL of the 
image in the javascript function.

something like this:


// In the mySite.js file
   var myImg = {{IMG(_src = URL('static','image/myImage.jpg') )}};
   
   function myFunction(){
   // use myImg variable here
   // the src attribute of myImg should be set to 
localhost/mySite/static/image/myImage.jpg
   };


Thanks!


-- 





[web2py] Re: custom built login form

2012-08-25 Thread shartha
You're awesome! Thank you Anthony!

On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:

 Hello, 
 Quick question:
 Instead of {{=auth.login()}}, I am using the following to be able to 
 customize my login form. However the resulting form does not work and I 
 cannot login with the same username/password that enable me to login if I 
 had used {{=auth.login()}} -- I get the flash error: Invalid Login.

 Could someone please tell me what's possibly going wrong? Thanks!

 {{form=auth.login()}}
 {{=form.custom.begin}} 
 Username:
 {{=form.custom.widget.username}}
 /br
 Password:
 {{=form.custom.widget.password}}
 {{=form.custom.submit}} 
 {{=form.custom.end}} 


-- 





[web2py] Re: Screenplay formatting with web2py - markdown2.py

2012-08-25 Thread Massimo Di Pierro
I do not know anything about the subject but a quick search yields:
http://johnaugust.com/2004/screenbox

So once could define:

.screenplay { font: 12px/14px Courier, fixed; width: 420px; background: 
#eee; border: 1px solid #333; padding: 5px 14px;}
.screenplay h2, .screenplay h3,  .screenplay blockquote { padding-top: 
1.5ex; }
.screenplay blockquote { padding-right: 5%; }
.screenplay h3 { margin-left: 40%; }
.screenplay p { margin-left: 25%; padding-right: 25%; }

and use {{=DIV(MARKMIN(screenplay),_class=screenplay)}}

where 

screenplay = 

## EXT. FOREST / ELSEWHERE - DAY

--

Susan is on a cell-phone call. She smiles at Melissa, who walks by with two 
cups of coffee.

--

### SUSAN (V.O.)

Right now, this is probably our top pilot. But things change.

### MELISSA

I have no idea what we are talking about. 


Massimo


On Saturday, 25 August 2012 11:42:08 UTC-5, Rob_McC wrote:

 Hi:

 Any thoughts on *screenplay formatting *for a web2py app?

 I've been studying markdown2.py
 and I think it could be easily? modified for Screenplay format.
easily?

 *Summary*:
 Screenplay have a very set, and old fashioned format:
 Here is example of standard format used in Hollywood today.

 -
 EXT. ANCIENT ROME — DAY

 ANTONIUS and IPSUM are walking down a tiny, crowded street.

  ANTONIUS
 (shaking his head)
 Do you think in a thousand years,
 anyone will remember our names?

  IPSUM
 Not yours. But they'll know mine.
 Because I intend to write something so
 profound that it will be remembered
 for the ages.

 Designers in the 20th Century will
 call for Lorem Ipsum whenever they
 need to fill text blocks.

 INT. BATHHOUSE – DAY

 Antonius is in the bathhouse.

 etc.
 -



 I want to use this (markdown-like) format to create the above
 *s:  is Scene
 a:  is Action
 c:  is Character
 p:  is Parenthetical
 d:  is Dialog*


 -
 s:EXT. ANCIENT ROME — DAY
 a:ANTONIUS and IPSUM are walking down a tiny, crowded street.
 c:ANTONIUS
 p:shaking his head
 d:Do you think in a thousand years, anyone will remember our names?
 c:IPSUM
 d:Not yours. But they'll know mine. Because I intend to write something so 
 profound that it will be remembered for the ages.

 Designers in the 20th Century will call for Lorem Ipsum whenever they need 
 to fill text blocks.

 s:INT. BATHHOUSE – DAY
 a:Antonius is in the bathhouse.

 etc.
 -

 Thanks for your opinions. Of course, a PDF would be the next step...

 Rob


 ---
 Ref:

 http://code.google.com/searchframe#uyCl3L51_dI/gluon/contrib/markdown/markdown2.pyq=markdown%20package:web2py\.googlecode\.comsq=l=33ct=rccd=2http://code.google.com/searchframe#uyCl3L51_dI/gluon/contrib/markdown/markdown2.pyq=markdown%20package:web2py%5C.googlecode%5C.comsq=l=33ct=rccd=2


 I am aware of this http://fountain.io/scrippets
 which looks very good, but I would prefer a little more control using 
 a:  type of syntax. I wrote a 109 page script with Fountain format just 
 recently.

 Fountain makes heavy use of regular expressions...




-- 





Re: [web2py] Major speed improvement need testers

2012-08-25 Thread Massimo Di Pierro
Exactly. 

mytable.myfield.set_attributes(readable=True,writable=True)

is just a shortcut for

   mytable.myfield.readable=True
   mytable.myfield.writable=True

without it the lambda notation would not be very usable.

On Saturday, 25 August 2012 11:50:10 UTC-5, Jonathan Lundell wrote:

 On 23 Aug 2012, at 7:25 AM, Massimo Di Pierro 
 massimo@gmail.comjavascript: 
 wrote: 
  So now in trunk you can do: 
  
  db = DAL(lazy_tables=True) 
  db.define_table('person',Field('name'),Field('age','integer'), 
 on_define=lambda table: [ 

  table.name.set_attributes(requires=IS_NOT_EMPTY(),default=''), 

  table.age.set_attributes(requires=IS_INT_IN_RANGE(0,120),default=30), 
]) 
  
  and the attributes will be set lazily. This is a good idea! Thanks 
 Jonathan. 
  

 Clear something up for me, please. I was a little confused before about 
 how this was implemented, but I've read the code and it looks like what I 
 proposed. What I'm not following is the role of set_attributes. Is it 
 simply to facilitate the lambda? Is this equivalent? 

 def on_define(table): 
  table.name.requires = IS_NOT_EMPTY() 
  table.name.default = '' 
  table.age.requires = IS_INT_IN_RANGE(0,120) 
  table.age.default = 30 

 db = DAL(lazy_tables=True) 
 db.define_table('person', Field('name'), Field('age','integer'), 
 on_define=on_define) 


-- 





[web2py] Re: DAL not returning results on temp table query

2012-08-25 Thread Yarin
Thanks Simone- yeah I just figured this out. Though I actually went a 
different route and just stuffed it all in a stored procedure..

On Saturday, August 25, 2012 2:52:42 PM UTC-4, Niphlod wrote:

 I think the DBAPI doesn't support several results set in a single 
 statement.

 If you cared to do those one line at a time you'd noticed that:
 create temporary table tmp like people does not return results.
 insert into tmp select * from people returns the just inserted values
 select * from tmp returns your lines.

 I think that as long as you have only one statement (and it's the last ) 
 in your executesql() wrapped string you'll be fine. If some of your lines 
 returns results, then the driver doesn't know what set to actually return.
 Anyway splitting those lines in multiple db.executesql()s is working great.

 On Saturday, August 25, 2012 5:58:40 PM UTC+2, Yarin wrote:

 I'm trying to execute some SQL from the DAL that relies on a temp table:

 CREATE TEMPORARY TABLE tmp LIKE people;

  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;


 This code works fine in a SQL panel, but fails when used in the DAL:

 def test():


  db_test = DAL('mysql://root:root@localhost/test')
  
  sql = CREATE TEMPORARY TABLE tmp LIKE people;
  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;
  
  results = db_test.executesql(sql)


 Results always returns None. No idea why or how to proceed.



-- 





[web2py] Re: DAL not returning results on temp table query

2012-08-25 Thread Massimo Di Pierro
Exately. On top of this until yesterday executesql had a try fetchall() 
except return None. which is now gone. If you get the latest web2py from 
trunk it should give you an error.

On Saturday, 25 August 2012 13:52:42 UTC-5, Niphlod wrote:

 I think the DBAPI doesn't support several results set in a single 
 statement.

 If you cared to do those one line at a time you'd noticed that:
 create temporary table tmp like people does not return results.
 insert into tmp select * from people returns the just inserted values
 select * from tmp returns your lines.

 I think that as long as you have only one statement (and it's the last ) 
 in your executesql() wrapped string you'll be fine. If some of your lines 
 returns results, then the driver doesn't know what set to actually return.
 Anyway splitting those lines in multiple db.executesql()s is working great.

 On Saturday, August 25, 2012 5:58:40 PM UTC+2, Yarin wrote:

 I'm trying to execute some SQL from the DAL that relies on a temp table:

 CREATE TEMPORARY TABLE tmp LIKE people;

  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;


 This code works fine in a SQL panel, but fails when used in the DAL:

 def test():


  db_test = DAL('mysql://root:root@localhost/test')
  
  sql = CREATE TEMPORARY TABLE tmp LIKE people;
  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;
  
  results = db_test.executesql(sql)


 Results always returns None. No idea why or how to proceed.



-- 





[web2py] Re: set a javascript variable using web2py helpers

2012-08-25 Thread Massimo Di Pierro
You can. I am not sure if you need

var myImg = '{{=IMG(_src = URL('static','image/myImage.jpg') )}}'; // 
single quotes contain 'img /'

or

var myImg = {{=URL('static','image/myImage.jpg')}}; // url only



On Saturday, 25 August 2012 14:56:05 UTC-5, shartha wrote:

 Hi, 

 Is there any way to set the value of a global javascript variable defined 
 in a .js file using web2py helpers?
 I have an image in my static/image folder and I want to use the URL of the 
 image in the javascript function.

 something like this:


 // In the mySite.js file
var myImg = {{IMG(_src = URL('static','image/myImage.jpg') )}};

function myFunction(){
// use myImg variable here
// the src attribute of myImg should be set to 
 localhost/mySite/static/image/myImage.jpg
};


 Thanks!




-- 





[web2py] Re: custom built login form

2012-08-25 Thread Massimo Di Pierro
+1

On Saturday, 25 August 2012 14:57:53 UTC-5, shartha wrote:

 You're awesome! Thank you Anthony!

 On Tuesday, August 14, 2012 10:51:12 PM UTC-7, shartha wrote:

 Hello, 
 Quick question:
 Instead of {{=auth.login()}}, I am using the following to be able to 
 customize my login form. However the resulting form does not work and I 
 cannot login with the same username/password that enable me to login if I 
 had used {{=auth.login()}} -- I get the flash error: Invalid Login.

 Could someone please tell me what's possibly going wrong? Thanks!

 {{form=auth.login()}}
 {{=form.custom.begin}} 
 Username:
 {{=form.custom.widget.username}}
 /br
 Password:
 {{=form.custom.widget.password}}
 {{=form.custom.submit}} 
 {{=form.custom.end}} 



-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread apps in tables

My point (case) is :

For the parts where a model is not known in advance, you can use the 
underlying NoSQL adapter of your choice to accomplish everything you want. 

My question is:

What will be the structure of the application in that case? controller , 
view , no model.,

My very simple question is:

what will the application will look like ( flow of screens shown to the 
user ) in that case ? 

If you know of even any example in any language, Please let me know.

Regards,

Ashraf

-- 





Re: [web2py] Error when assigning form.vars

2012-08-25 Thread SeamusSeamus
Thanks! 

On Saturday, August 25, 2012 1:37:55 PM UTC-6, Jonathan Lundell wrote:

 On 25 Aug 2012, at 12:27 PM, SeamusSeamus 
 morrisjam...@gmail.comjavascript: 
 wrote:

 When I do this:
 form=SQLFORM.factory(
 Field('your_email',requires=IS_EMAIL()),
 Field('your_phone'),
 Field('subject'),
 Field('question', 'text', requires=IS_NOT_EMPTY()))
 form.vars = dict(subject='Item %s: %s' % (database.id, 
 database.title))


 form.vars needs to be Storage, not dict.

 if form.process().accepted:
 if mail.send(to=...@domain.com javascript:',
 subject='Regarding %s' % form.vars.subject,
 message='From %s at %s: %s' % (form.vars.your_email, 
 form.vars.your_phone, form.vars.question)):
 response.flash='Your message has been sent! We will contact 
 you shortly.'
 elif form.errors:
 form.errors.your_email='Unable to send email'

 return dict(equipment=equipment, form=form)


 I get this error:

 Traceback (most recent call last):
   File /home/james/web2py/gluon/restricted.py, line 205, in restricted
 exec ccode in environment
   File /home/james/web2py/applications/equipment/controllers/default.py 
 http://127.0.0.1:8000/admin/edit/equipment/controllers/default.py, line 
 309, in module
   File /home/james/web2py/gluon/globals.py, line 173, in lambda
 self._caller = lambda f: f()
   File /home/james/web2py/applications/equipment/controllers/default.py 
 http://127.0.0.1:8000/admin/edit/equipment/controllers/default.py, line 
 179, in details
 if form.process().accepted:
   File /home/james/web2py/gluon/html.py, line 1994, in process
 self.validate(**kwargs)
   File /home/james/web2py/gluon/html.py, line 1941, in validate
 if self.accepts(**kwargs):
   File /home/james/web2py/gluon/sqlhtml.py, line 1274, in accepts
 self.vars.id = self.table.insert(**fields)
 AttributeError: 'dict' object has no attribute 'id'



 PS: What is the best way to provide a condition in case mail sending fails?

 -- 
  
  
  





-- 





Re: [web2py] Re: DAL not returning results on temp table query

2012-08-25 Thread Yarin Kessler
Massimo- good, that's help- thanks

On Sat, Aug 25, 2012 at 4:39 PM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 Exately. On top of this until yesterday executesql had a try fetchall()
 except return None. which is now gone. If you get the latest web2py from
 trunk it should give you an error.


 On Saturday, 25 August 2012 13:52:42 UTC-5, Niphlod wrote:

 I think the DBAPI doesn't support several results set in a single
 statement.

 If you cared to do those one line at a time you'd noticed that:
 create temporary table tmp like people does not return results.
 insert into tmp select * from people returns the just inserted values
 select * from tmp returns your lines.

 I think that as long as you have only one statement (and it's the last )
 in your executesql() wrapped string you'll be fine. If some of your lines
 returns results, then the driver doesn't know what set to actually return.
 Anyway splitting those lines in multiple db.executesql()s is working
 great.

 On Saturday, August 25, 2012 5:58:40 PM UTC+2, Yarin wrote:

 I'm trying to execute some SQL from the DAL that relies on a temp table:

 CREATE TEMPORARY TABLE tmp LIKE people;

  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;


 This code works fine in a SQL panel, but fails when used in the DAL:

 def test():


  db_test = DAL('mysql://root:root@**localhost/test')

  sql = CREATE TEMPORARY TABLE tmp LIKE people;
  INSERT INTO tmp SELECT * FROM people;
  INSERT INTO tmp SELECT * FROM people;
  SELECT * FROM tmp;

  results = db_test.executesql(sql)


 Results always returns None. No idea why or how to proceed.

  --





-- 





[web2py] Category and Subcategory

2012-08-25 Thread SeamusSeamus
Right now I am categorizing my products by 'category' and 'subcategory' 
using smartgrid. This makes it very easy for me to log in and set my cats 
and sub cats. I have two tables below. 

db.define_table('cat',
Field('name'),
format = '%(name)s'
)

db.define_table('subcat',
Field('cat', 'reference cat'),
Field('name'),
format = '%(name)s'
)

 I also have a third table for the product:

db.define_table('equipment',
...
Field('category', db.cat),
Field('subcategory', db.subcat, label=Sub-Category)
...
)

I am using this as my controller:

def productadmin():

fields = [db.equipment.title, db.equipment.approved]

grid = SQLFORM.grid(db.equipment, fields=fields)

return dict(grid=grid)


Here is my question.
 When I click on 'edit' in the sqlform.grid for an item, and I want to 
change the category or assign the category, how do I make it so only the 
subcat will show if it is truly a subcat for the category? Currently, I 
have a list of all my cats and a list of all my subcats.


-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread apps in tables
A nice aticle

http://www.aosabook.org/en/nosql.html 

I am still looking for schema-free application example.


 Regards,

 Ashraf


-- 





[web2py] Re: Web2Py on OpenShift

2012-08-25 Thread greaneym
Hi Andrew,

I am using your web2py build on openshift and noticed today that you 
submitted a bug report for wsgi  that was 
causing your access to the web2py admin tool to fail.  I wonder if you have 
tried the ssh tunneling steps in the web2py manual in 13.3 but using a port 
that openshift does not block.  Did that work for you? Has anyone tried 
this on openshift?

I am still learning the openshift rules and haven't gotten this to work yet 
but would like to as it would be good to be
able to use the admin tool over the browser in a secure way.

Margaret

On Friday, June 8, 2012 10:07:39 AM UTC-5, Andrew wrote:

 Just FYI to anyone interested, I've put together a web2py template for 
 OpenShift https://openshift.redhat.com/app/ (Red Hat's Opensource 
 PaaS). 

 You can find it here: - https://github.com/prelegalwonder/openshift_web2py

 I've also put together a basic openshift deployer from the admin page, and 
 you can grab the changes from my fork of web2py - 
 https://github.com/prelegalwonder/web2py
 It's just 3 files in the admin app:
  controllers/openshift.py
  views/openshift/deploy.html
 and a modification to views/default/site.html

 It's only requirement to work beyond having a local working openshift 
 project is GitPython installed and accessible from the runtime that web2py 
 is running in.

 So you can either run the admin app in the cloud and access it directly or 
 run a local web2py instance and execute the deployer when you want to test 
 out your changes. 

 I'm working on a detailed blog that I intent to submit to the OpenShift 
 team so they can put it on their site for getting started. 

 Enjoy


-- 





[web2py] Defining stored procedures

2012-08-25 Thread Yarin
I'm assuming there's probably no support for defining stored procedures 
using DAL functions. Instead I was going to try to create them in raw sql 
using executesql whenever migrate was turned on. Just wondering if this is 
the best technique, or someone has another idea


-- 





[web2py] Re: Category and Subcategory

2012-08-25 Thread Anthony
That kind of thing has to be done via Javascript on the client side. For 
some references, see 
http://stackoverflow.com/questions/8146260/best-practice-for-populating-dropdown-based-on-other-dropdown-selection-in-web2p/8152910#8152910
.

Anthony

On Saturday, August 25, 2012 5:34:14 PM UTC-4, SeamusSeamus wrote:

 Right now I am categorizing my products by 'category' and 'subcategory' 
 using smartgrid. This makes it very easy for me to log in and set my cats 
 and sub cats. I have two tables below. 

 db.define_table('cat',
 Field('name'),
 format = '%(name)s'
 )

 db.define_table('subcat',
 Field('cat', 'reference cat'),
 Field('name'),
 format = '%(name)s'
 )

  I also have a third table for the product:

 db.define_table('equipment',
 ...
 Field('category', db.cat),
 Field('subcategory', db.subcat, label=Sub-Category)
 ...
 )

 I am using this as my controller:

 def productadmin():

 fields = [db.equipment.title, db.equipment.approved]

 grid = SQLFORM.grid(db.equipment, fields=fields)

 return dict(grid=grid)


 Here is my question.
  When I click on 'edit' in the sqlform.grid for an item, and I want to 
 change the category or assign the category, how do I make it so only the 
 subcat will show if it is truly a subcat for the category? Currently, I 
 have a list of all my cats and a list of all my subcats.




-- 





[web2py] Re: Defining stored procedures

2012-08-25 Thread Anthony
Do they need to be created dynamically by your app? If not, you could just 
create them outside of web2py.

Side note -- if you want web2py to generate SQL for any queries, you can 
form the queries as usual and call the ._select() method instead of 
.select() -- that will return the SQL as a string rather than actually 
running the query.

Anthony

On Saturday, August 25, 2012 5:56:10 PM UTC-4, Yarin wrote:

 I'm assuming there's probably no support for defining stored procedures 
 using DAL functions. Instead I was going to try to create them in raw sql 
 using executesql whenever migrate was turned on. Just wondering if this 
 is the best technique, or someone has another idea




-- 





Re: [web2py] Re: Defining stored procedures

2012-08-25 Thread Yarin Kessler
Yeah I could create them outside of web2py, was just wondering if there was
a good way to perform SQL 'prep' on a db along with the table migrations..
not critical though.

On Sat, Aug 25, 2012 at 6:29 PM, Anthony abasta...@gmail.com wrote:

 Do they need to be created dynamically by your app? If not, you could just
 create them outside of web2py.

 Side note -- if you want web2py to generate SQL for any queries, you can
 form the queries as usual and call the ._select() method instead of
 .select() -- that will return the SQL as a string rather than actually
 running the query.

 Anthony


 On Saturday, August 25, 2012 5:56:10 PM UTC-4, Yarin wrote:

 I'm assuming there's probably no support for defining stored procedures
 using DAL functions. Instead I was going to try to create them in raw sql
 using executesql whenever migrate was turned on. Just wondering if this
 is the best technique, or someone has another idea


  --





-- 





[web2py] Re: set a javascript variable using web2py helpers

2012-08-25 Thread Anthony


 Enter code here...

 // In the mySite.js file
var myImg = {{IMG(_src = URL('static','image/myImage.jpg') )}};


Note, the above will only work if mySite.js is a web2py template and the 
file is served by calling a web2py action (i.e., it can't be a static 
file). Another approach, though, is to leave that variable declaration out 
of mySite.js. Instead, include the variable declaration someplace like 
layout.html, right before wherever you load the mySite.js file -- that way 
the variable will be defined before any code in mySite.js references it.

script
  var myImg = {{=IMG(_src = URL('static','image/myImage.jpg'))}}
/script
script src={{=URL('static', 'js/mySite.js')}}/script

This strategy is used in web2py_ajax.html in order to dynamically define a 
few variables needed within web2py.js (which is served as a static file).

Yet another option is to make myImg a parameter of your function in 
mySite.js and pass it in a web2py template when you call that function:

In mySite.js:

function myFunction(myImg) {
   // use myImg variable here
};

In layout.html and/or the page-specific view:

script src={{=URL('static', 'js/mySite.js')}}/script
script
  [some code]
  myFunction({{=IMG(_src = URL('static','image/myImage.jpg'))}});
  [more code]
/script

Anthony

-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread Anthony


 but this all leads me to the realization that web2py does
 not give a value to the form field of a SQLFORM until the form
 is processed, is there a request.vars.id that can
 be used before processing?


Note, the id is the record id of the record added to the database. The 
record cannot be added to the database until after validation has passed, 
and you cannot therefore get a record id until after the form has been 
processed an accepted. Why do you need a database record id before the 
record is even inserted into the database?

Anthony

-- 





Re: [web2py] Re: Defining stored procedures

2012-08-25 Thread Anthony
I suppose executesql would be fine in that case if you want to do it that 
way.

On Saturday, August 25, 2012 6:34:18 PM UTC-4, Yarin wrote:

 Yeah I could create them outside of web2py, was just wondering if there 
 was a good way to perform SQL 'prep' on a db along with the table 
 migrations.. not critical though.

 On Sat, Aug 25, 2012 at 6:29 PM, Anthony abas...@gmail.com 
 javascript:wrote:

 Do they need to be created dynamically by your app? If not, you could 
 just create them outside of web2py.

 Side note -- if you want web2py to generate SQL for any queries, you can 
 form the queries as usual and call the ._select() method instead of 
 .select() -- that will return the SQL as a string rather than actually 
 running the query.

 Anthony


 On Saturday, August 25, 2012 5:56:10 PM UTC-4, Yarin wrote:

 I'm assuming there's probably no support for defining stored procedures 
 using DAL functions. Instead I was going to try to create them in raw sql 
 using executesql whenever migrate was turned on. Just wondering if this 
 is the best technique, or someone has another idea


  -- 
  
  
  




-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread SeamusSeamus
This runs into a problem where if I have two items of the same 'title', the 
user will only be linked to the first one that was created. Can I make it 
so the slug is a field that I designate? Or make it so the slug adds a 
incrementing number such as:
Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*)[0])
 I know thats not how you do it, but do you get what I mean? Is there a 
better way?


On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:

 links = [lambda ro
 w: A('Details',_href=URL('default','show', args=[row.slug]))]
 fields = [db.equipment.category, db.equipment.title, 
 db.equipment.price]


 You have not included slug in your list of fields, so I believe it will 
 not be included in the data query. Instead of specifying the list of 
 fields, you can set the readable attribute to False for fields you don't 
 want displayed (including slug). In that case, all fields will be 
 included in the query (including slug), but only the fields you want to 
 show will be visible in the grid.

 Anthony 


-- 





Re: [web2py] Re: NoSQL Question Again!!!

2012-08-25 Thread Niphlod
Ok, I think you have a problem with all the apps without a predefined 
model, not a problem with web2py.

I don't think there are out there applications without a model (some kind 
of model is required in programming, heck, even ideas in your brain 
are) but there are evolving applications. You start with a model, than 
you want to extend it.
Don't know if this is the best example, but, let's suppose you make an app 
to share recipes among users. Initially you think to have a simple user_id, 
recipe_content model. Then, you realize you can implement tags because now 
you have 1 unsorted recipes and your users will likely want to search 
through them in a somewhat organized manner. In a strictly modelled app, 
you'd have to sort out those 1 recipes and add tags (and force a None 
on every recipe that doesn't belong to a tag). In Nosql, you can have 100 
tagged recipes and leave all the others without any knowledge of a tag 
(that is a concept separated then having a tag==None associated to them).
Again, for the most detailed recipes (or the most contributive users), 
you'd like to implement a list of ingredients. You don't have to add an 
empty column containing the reference to the ingredients for just 10 users. 
In all of that, you end up having all your recipes with some common 
fields and some with additional ones, and you can query all of those in 
the same place. You'd have to sort out in the controller or in the view at 
some point what to print to the page.
Some companies work like that: it's best to unleash coders  from the 
standardized models to let features released sooner. And when you realize 
that having to add a column or a table to your app for 1m users take 100 
gigabytes and the migration will keep your site down for 6 hours that you 
can't simply afford, Nosql comes in handy. In the end it will be a mess 
compared to a standardized MVC app ? Probably, but not too much.

Don't forget that an app using a Nosql db can really have an added value 
also if strictly modelled. 
If you happen to notice that you require raw speed and a small amount of 
complicated joins that are solvable outside the db scope (e.g. an app to 
centralize the logs for a server facility) then a Nosql db may be more 
indicated than a full blown RDBMS. 

On Saturday, August 25, 2012 11:52:53 PM UTC+2, apps in tables wrote:

 A nice aticle

 http://www.aosabook.org/en/nosql.html 

 I am still looking for schema-free application example.


 Regards,

 Ashraf



-- 





[web2py] Re: SQLFORM id

2012-08-25 Thread pylix
I don't; just wondering if it was possible.
I reconfigured my app to get the vars after they're processed
I have no outstanding issues. for me this topic is closed.
thanks for all the responses and explanations.

On Saturday, August 25, 2012 6:57:09 PM UTC-4, Anthony wrote:

 but this all leads me to the realization that web2py does
 not give a value to the form field of a SQLFORM until the form
 is processed, is there a request.vars.id that can
 be used before processing?


 Note, the id is the record id of the record added to the database. The 
 record cannot be added to the database until after validation has passed, 
 and you cannot therefore get a record id until after the form has been 
 processed an accepted. Why do you need a database record id before the 
 record is even inserted into the database?

 Anthony


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread Anthony
Sure, something like that seems fine. Look at what SO does -- for example: 
http://stackoverflow.com/questions/12050934/web2py-build-forms-in-controller-or-view.
 
I think they use the number as the unique record identifier, but also 
include a slug (which doesn't necessarily have to be unique).

Anthony

On Saturday, August 25, 2012 7:16:50 PM UTC-4, SeamusSeamus wrote:

 This runs into a problem where if I have two items of the same 'title', 
 the user will only be linked to the first one that was created. Can I make 
 it so the slug is a field that I designate? Or make it so the slug adds a 
 incrementing number such as:
 Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*)[0])
  I know thats not how you do it, but do you get what I mean? Is there a 
 better way?


 On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:

 links = [lambda ro
 w: A('Details',_href=URL('default','show', args=[row.slug]))]
 fields = [db.equipment.category, db.equipment.title, 
 db.equipment.price]


 You have not included slug in your list of fields, so I believe it will 
 not be included in the data query. Instead of specifying the list of 
 fields, you can set the readable attribute to False for fields you don't 
 want displayed (including slug). In that case, all fields will be 
 included in the query (including slug), but only the fields you want to 
 show will be visible in the grid.

 Anthony 



-- 





[web2py] Option to visit Non-mobile site with @mobilize

2012-08-25 Thread Mark Li
I would like to add the option to visit the regular version of the site on 
the mobile-view.

However, from my understanding of @mobilize, it automatically redirects to 
the mobile version of the page if a mobile device is detected. Is there a 
way to override this behavior if a visitor on a mobile-device chooses the 
Non-mobile option for the site?

-- 





[web2py] Re: Option to visit Non-mobile site with @mobilize

2012-08-25 Thread Anthony
I don't think you can control that using the @mobilize decorator, but 
instead of using the decorator, you can use request.user_agent().is_mobile 
to detect mobile clients and make changes accordingly. The @mobilize 
decorator just does this:

user_agent = request.user_agent()
if user_agent.is_mobile:
items = response.view.split('.')
items.insert(-1,'mobile')
response.view = '.'.join(items)

You could add that logic yourself to a model file, but make it conditional 
so it isn't executed if the user has selected the desktop version (that 
choice can be stored in the session).

Anthony

On Saturday, August 25, 2012 8:04:57 PM UTC-4, Mark Li wrote:

 I would like to add the option to visit the regular version of the site on 
 the mobile-view.

 However, from my understanding of @mobilize, it automatically redirects to 
 the mobile version of the page if a mobile device is detected. Is there a 
 way to override this behavior if a visitor on a mobile-device chooses the 
 Non-mobile option for the site?


-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread SeamusSeamus
Thanks for the info Anthony...
When I do this:
Field('slug', compute=lambda row: IS_SLUG()(row.title + - + 
str(row.id))[0])

 I get none as a slug...



On Saturday, August 25, 2012 5:53:49 PM UTC-6, Anthony wrote:

 Sure, something like that seems fine. Look at what SO does -- for example: 
 http://stackoverflow.com/questions/12050934/web2py-build-forms-in-controller-or-view.
  
 I think they use the number as the unique record identifier, but also 
 include a slug (which doesn't necessarily have to be unique).

 Anthony

 On Saturday, August 25, 2012 7:16:50 PM UTC-4, SeamusSeamus wrote:

 This runs into a problem where if I have two items of the same 'title', 
 the user will only be linked to the first one that was created. Can I make 
 it so the slug is a field that I designate? Or make it so the slug adds a 
 incrementing number such as:
 Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*)[0])
  I know thats not how you do it, but do you get what I mean? Is there a 
 better way?


 On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:

 links = [lambda ro
 w: A('Details',_href=URL('default','show', args=[row.slug]))]
 fields = [db.equipment.category, db.equipment.title, 
 db.equipment.price]


 You have not included slug in your list of fields, so I believe it 
 will not be included in the data query. Instead of specifying the list of 
 fields, you can set the readable attribute to False for fields you don't 
 want displayed (including slug). In that case, all fields will be 
 included in the query (including slug), but only the fields you want to 
 show will be visible in the grid.

 Anthony 



-- 





Re: [web2py] Re: SEO Friendly URLs and Page Titles

2012-08-25 Thread Anthony
Oh, yeah, I guess you probably can't use the id in a compute because there 
is no id until the record has been inserted. You could instead make the id 
part of the URL (like Stack Overflow), or maybe make it a virtual field, or 
generate your own unique id (separate from the record id).

Anthony

On Saturday, August 25, 2012 8:34:22 PM UTC-4, SeamusSeamus wrote:

 Thanks for the info Anthony...
 When I do this:
 Field('slug', compute=lambda row: IS_SLUG()(row.title + - + str(
 row.id))[0])

  I get none as a slug...



 On Saturday, August 25, 2012 5:53:49 PM UTC-6, Anthony wrote:

 Sure, something like that seems fine. Look at what SO does -- for 
 example: 
 http://stackoverflow.com/questions/12050934/web2py-build-forms-in-controller-or-view.
  
 I think they use the number as the unique record identifier, but also 
 include a slug (which doesn't necessarily have to be unique).

 Anthony

 On Saturday, August 25, 2012 7:16:50 PM UTC-4, SeamusSeamus wrote:

 This runs into a problem where if I have two items of the same 'title', 
 the user will only be linked to the first one that was created. Can I make 
 it so the slug is a field that I designate? Or make it so the slug adds a 
 incrementing number such as:
 Field('slug', compute=lambda row: IS_SLUG()(row.title *+ row.id*
 )[0])
  I know thats not how you do it, but do you get what I mean? Is there a 
 better way?


 On Thursday, August 23, 2012 1:18:16 AM UTC-6, Anthony wrote:

 links = [lambda ro
 w: A('Details',_href=URL('default','show', args=[row.slug]))]
 fields = [db.equipment.category, db.equipment.title, 
 db.equipment.price]


 You have not included slug in your list of fields, so I believe it 
 will not be included in the data query. Instead of specifying the list of 
 fields, you can set the readable attribute to False for fields you don't 
 want displayed (including slug). In that case, all fields will be 
 included in the query (including slug), but only the fields you want to 
 show will be visible in the grid.

 Anthony 



--