[web2py] headers argument behavior in v1.97.1

2011-07-06 Thread niknok
While using crud, I sometimes define headers for *some* fields listed in
the fields argument. This works until I upgraded to 1.97.1 and now I get
an error if I do not define the headers for *all* fields listed in the
fields argument.

For example, the following code no longer works

rows=crud.select(db.address
,query=((db.address.owner_is==address_owner)&

(db.address.owner_is_person==address_owner_is_person))
,fields=['address.id'
,'address.line_1'
,'address.is_type'
,'address.country']
,headers={'address.id':'#'
,'address.line_1':'Street address'
,'address.country':'Country'})


until I add a header for address.is_type, too. 

Is this a bug or a new feature?


[web2py] Re: Check

2011-07-06 Thread beedge
Apologises.

Stupid.  Double (differeing) definition of db in the model file,
before and after some custom auth tables.  Hence, app was pulling in
my apps tables, but I couldn't see the auth stuff and odd behaviour.



Re: [web2py] Re: Query construction question

2011-07-06 Thread Martin Barnard
No. There is a good chance that the person who uploaded the memo
(db.memo_store.created_by) is not the same as the person viewing the memo
(db.viewed_memos.created_by).
My solution, for people who are interested in something similar:

def unread_memos():
"""
Will return a list of all unread memos
"""
# We want to count the # of memos which we haven't looked at
read_memos=db(db.viewed_memos.created_by==auth.user_id).select(
db.viewed_memos.memo, groupby=db.viewed_memos.memo)
mul=[] # Our read memos list
if len(read_memos) > 0:
for row in read_memos:
mul.append(row.memo)
unread=db(~db.memo_store.id.belongs(mul)).select(db.memo_store.ALL,

orderby=~db.memo_store.created_on)
else:
unread=db(db.memo_store).select(db.memo_store.ALL,
orderby=~db.memo_store.created_on)

return dict(unread_rows=unread)


On 6 July 2011 08:14, pbreit  wrote:

> I don't totally understand but would this do it?
>
> db(db.memo_store.created_by==auth.user.id)(db.viewed_memos.memo==
> db.memo_store.id).select()
>


Re: [web2py] cron "Too many open files" regression?

2011-07-06 Thread John Duddy
None that I know of. The processes that accumulate have the same
arguments as the main web2py process (as shown by ps -ef) so it's like
a fork with no exec.

On Wednesday, July 6, 2011, ron_m  wrote:
> Maybe one possibility is if your code has classes with a __del__ method in 
> them, Massimo would have better perspective on if this is a possibility. If a 
> class with this method is involved in a circular reference the garbage 
> collector cannot clean it up because of uncertainty of execution of the 
> __del__ method. This was discussed a lot on the group a few months back. I 
> believe exec also has to be involved. Do a search for __del__ in the group to 
> see what was said. There were also some tools mentioned in those threads that 
> help with tracking down this sort of problem.
>
> I find in Python as soon as a file variable binding produced by open goes out 
> of scope it is closed, you don't have to specifically call close on it. 
> Normally objects are dropped as soon as the reference count reaches 0. The 
> garbage collector was added to clean up the circular referenced objects that 
> will never get a count down to 0 without some outside help. It searches the 
> heap looking for objects that have no references except other objects also in 
> the garbage and marks those as candidates to clean out. The fact that these 
> file objects are piling up means something is holding the file reference 
> which also cannot be cleaned up.
>
> Are you running on Linux? If so the /proc/pid_of_web2py/fd directory using ls 
> -l will show you what files by name are open to the process which might 
> provide some clues to which part of your code.
>

-- 
John Duddy
jdu...@gmail.com


Re: [web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves
In fact, just to make sure there wasn't something hidden in my app affecting
the behavior,
I downloaded a fresh install of web2py,

and get the same error:

  File "/home/pierluigi/web2py/gluon/tools.py", line 1796, in register

user = self.db(table_user[username] == form.vars[username]).select().first()
KeyError: 'email'


Adding just this code to the 'welcome' app:

 def user():
  if request.args(0)=='register':

  auth.settings.table_user.email.default = 'l...@vision.caltech.edu'

  auth.settings.table_user.email.writable=False


  auth.settings.registration_requires_verification = False

  return dict(form=auth())

L.

On Wed, Jul 6, 2011 at 8:35 PM, Luis Goncalves  wrote:

> Yes, when I click on the invite and go to the website I get the
> registration form filled out with email (and name (excluded from my
> shortened example)) visible and non-editable.
>
> Luis.
>
> —«sent by mobile»—
> On Jul 6, 2011 8:17 PM, "Massimo Di Pierro" 
> wrote:
> > Are you sure your db.registrant has an email?
> >
> > On Jul 6, 10:04 pm, Luis Goncalves  wrote:
> >> I still get the same error:
> >>
> >>   File "/home/ubuntu/web2py/gluon/tools.py", line 1683, in register
> >> user = self.db(table_user[username] ==
> form.vars[username]).select().first()
> >> KeyError: 'email'
> >>
> >> I don't know if it makes a difference or not, but I'm using emails for
> login
> >> (not a username) -- as is probably clear to you from the above error.
> >>
> >> Code is now:
> >>
> >>   def user():
> >>
> >>   if request.args(0)=='register':
> >>
> >>   registrant = db( db.registrant.token == request.vars.token
> >> ).select().first()
> >>
> >>   auth.settings.table_user.email.default = registrant.email
> >>   auth.settings.table_user.email.writable=False
> >>
> >>   auth.settings.registration_requires_verification = False
> >>
> >>   return dict(form=auth())
>


[web2py] Web2py and jython

2011-07-06 Thread Alfonso de la Guarda
Hello,

I will start a business project that needs create a web layer in front of
Adampiere / Open Bravo for hospital / clinic operation.
We will avoid JAVA, but need some of the objects provided in those ERPs,
because that jython is the best choice.
I choose web2py for the weblayer, but at the start, when simply do a jython
web2py.py shows an error message

OSError: [Errno 0] chdir not supported in Java: /home/alfonsodg/Devel/web2py

*The error message is pretty clear, but if works in jython from start, why
this error? (simply chdir is not allowed)*
*What is the experience from you with web2py and jython? is really good
enough?*
*Any ideas will be gladly received.*
*
*


Saludos,


Alfonso de la Guarda
Centro Open Source(COS)
http://www.cos-la.net
http://alfonsodg.net
   Telef. 991935157
1024D/B23B24A4
5469 ED92 75A3 BBDB FD6B  58A5 54A1 851D B23B 24A4


Re: [web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves
Yes, when I click on the invite and go to the website I get the registration
form filled out with email (and name (excluded from my shortened example))
visible and non-editable.

Luis.

—«sent by mobile»—
On Jul 6, 2011 8:17 PM, "Massimo Di Pierro" 
wrote:
> Are you sure your db.registrant has an email?
>
> On Jul 6, 10:04 pm, Luis Goncalves  wrote:
>> I still get the same error:
>>
>>   File "/home/ubuntu/web2py/gluon/tools.py", line 1683, in register
>> user = self.db(table_user[username] ==
form.vars[username]).select().first()
>> KeyError: 'email'
>>
>> I don't know if it makes a difference or not, but I'm using emails for
login
>> (not a username) -- as is probably clear to you from the above error.
>>
>> Code is now:
>>
>>   def user():
>>
>>   if request.args(0)=='register':
>>
>>   registrant = db( db.registrant.token == request.vars.token
>> ).select().first()
>>
>>   auth.settings.table_user.email.default = registrant.email
>>   auth.settings.table_user.email.writable=False
>>
>>   auth.settings.registration_requires_verification = False
>>
>>   return dict(form=auth())


[web2py] Re: requires_permission example

2011-07-06 Thread Tim Korb
Thanks for your reply. 

My confusion is about "object" when it is not a table.  For one thing, the 
appadmin interface seems to force the object to be a table--it is chosen 
from the drop down box of available tables.  Do I have to create a dummy 
table for each of these permission objects?

Beyond the mechanics, what s the purpose of "object" when it is not a table? 
 Is it an extra level of refinement on the permission system?  Elaborating 
on this example from the book, does a statement like...

auth.add_permission(calculator, 'add', 'number')


say that members of group calculator are allowed to add numbers?  Whereas, a 
statement like...

auth.add_permission(stringers, 'add', 'string')


says that members of group stringers can also add, but strings instead of 
numbers? 

And in both cases, as I understand it, in contrast to the permissions on 
tables, there is no built-in support to actually enforce these permissions, 
beyond decorating all my functions correctly.

Tim


[web2py] Re: pyodbc access to Teradata (via web2py)

2011-07-06 Thread Andrew
Thankyou Massimo,

I have been able to connect OK to a Teradata database based on the
change to dal.py.  An important parameter to specify in the DAL for
Terdata is "DATABASE=xyz" to set the default database.  This worked OK
as is.

There are a few differences between DB2 and Teradata though (as I am
learning):
Teradata does not have a IDENTITY_VAL_LOCAL() equivalent.  For now,
I've added to the Teradata Adaptor:
def lastrowid(self,table):
return None
I am also experimenting with tables that are non auto increment
(following the legacy examples in the book) as these are more typical
in Teradata.  Note: Teradata Identity columns do not increment by 1,
they will ensure uniqueness but due to the parallel architecture the
next number won't necessarily be 1 more than the last one.
I created a table with integer PK columns but the insert statement
generated by web2py is attempting to insert NULL values.  I'm getting
lots of Rollbacks too.
As I've only just got this working and I'm new to web2py, I'll keep
experimenting with different combinations to see if I can pin it down.
Thanks for your help Massimo.

P.S.  How do I get the shell to put in a line feed in the output
window, or is this normal.  Would make it easier to read ?
P.P.S.  If I want to run executesql statements, does the table I'm
referencing need to be defined in the model ?


[web2py] Re: talks

2011-07-06 Thread Massimo Di Pierro
Here is more about my talk in San Francisco on July 13

http://www.meetup.com/sfpython/events/24721631/

Look forward to see some of you.

Massimo


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Massimo Di Pierro
Are you sure your db.registrant has an email?

On Jul 6, 10:04 pm, Luis Goncalves  wrote:
> I still get the same error:
>
>   File "/home/ubuntu/web2py/gluon/tools.py", line 1683, in register
>     user = self.db(table_user[username] == 
> form.vars[username]).select().first()
> KeyError: 'email'
>
> I don't know if it makes a difference or not, but I'm using emails for login
> (not a username) -- as is probably clear to you from the above error.
>
> Code is now:
>
>   def user():
>
>       if request.args(0)=='register':
>
>           registrant = db( db.registrant.token == request.vars.token
> ).select().first()
>
>           auth.settings.table_user.email.default = registrant.email
>           auth.settings.table_user.email.writable=False
>
>           auth.settings.registration_requires_verification = False
>
>       return dict(form=auth())


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves
I still get the same error:

  File "/home/ubuntu/web2py/gluon/tools.py", line 1683, in register
user = self.db(table_user[username] == form.vars[username]).select().first()
KeyError: 'email'


I don't know if it makes a difference or not, but I'm using emails for login 
(not a username) -- as is probably clear to you from the above error.

Code is now:

  def user():
  
  if request.args(0)=='register':
  
  registrant = db( db.registrant.token == request.vars.token 
).select().first()
  
  auth.settings.table_user.email.default = registrant.email
  auth.settings.table_user.email.writable=False
  
  auth.settings.registration_requires_verification = False
  
  return dict(form=auth())



[web2py] found it

2011-07-06 Thread beedge
Found the error after putting it down then reading through my .db file
from start to finish.  It was something silly, I defined the database
at two different points in the file, one being after the new auth
table.  Remove it and everything works as it should.  Apologises &
thanks...


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Massimo Di Pierro
My example did not have the line:

 form=auth.register()

On Jul 6, 1:39 pm, Luis Goncalves  wrote:
> Both with Massimo's
>
>           auth.settings.table_user.email.default = registrant.email
>           auth.settings.table_user.email.writable=False
>
>           form=auth.register()
>
> and with your
>
>           db[auth.settings.table_user_name].email.writable=False
>           db[auth.settings.table_user_name].email.default=registrant.email
>
>           form=auth.register()
>
> I get the error
>
> Exception: Target receiver address not specified
>
> at the line of    form=auth.register()
>
> For reference, the entire block (with error handling removed for clarity)
> is:
>
>   def user():
>
>       if request.args(0)=='register':
>
>           registrant = db( db.registrant.token == request.vars.token
> ).select().first()
>
>           db[auth.settings.table_user_name].email.writable=False
>           db[auth.settings.table_user_name].email.default=registrant.email
>
>           form=auth.register()
>
>           return dict(form=form)
>
> return dict(form=auth())


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves
Actually, I still want email verification to happen (because someone else 
may stumble upon the link and register with a password unknown to the real 
user). 

Nevertheless, I disabled registration verification, and now I get an error 
deep within  gloun/tools.py
Error occurs after entering password and submitting the form.
(same error with your and Massimo's version of the solution):

  File "/home/ubuntu/web2py/gluon/tools.py", line 1683, in register
user = self.db(table_user[username] == form.vars[username]).select().first()
KeyError: 'email'

Maybe making table_user.email.writable=False  
prevents auth.register() from creating a new table entry for the new user???

Again, for reference, the (essential) code:

  def user():
  
  if request.args(0)=='register':
  
  registrant = db( db.registrant.token == request.vars.token 
).select().first()

  auth.settings.registration_requires_verification = False
  
  db[auth.settings.table_user_name].email.writable=False
  db[auth.settings.table_user_name].email.default=registrant.email

  # this causes same error
  # auth.settings.table_user.email.default = registrant.email
  # auth.settings.table_user.email.writable=False

  
  form=auth.register()
  
  return dict(form=form) 

return dict(form=auth())



[web2py] Re: Check

2011-07-06 Thread ron_m
If you started with a copy of the Welcome app did you change the database 
name? If both apps have the same database URL originally defined in the 
Welcome app in file models/db.py they will share tables.


[web2py] Re: cron "Too many open files" regression?

2011-07-06 Thread Massimo Di Pierro
This should not be a problem because cron jobs are executed in their
own processes (not threads) and they should just die.
Anyway, I cannot completely exclude it either.

On Jul 6, 6:32 pm, ron_m  wrote:
> Maybe one possibility is if your code has classes with a __del__ method in
> them, Massimo would have better perspective on if this is a possibility. If
> a class with this method is involved in a circular reference the garbage
> collector cannot clean it up because of uncertainty of execution of the
> __del__ method. This was discussed a lot on the group a few months back. I
> believe exec also has to be involved. Do a search for __del__ in the group
> to see what was said. There were also some tools mentioned in those threads
> that help with tracking down this sort of problem.
>
> I find in Python as soon as a file variable binding produced by open goes
> out of scope it is closed, you don't have to specifically call close on it.
> Normally objects are dropped as soon as the reference count reaches 0. The
> garbage collector was added to clean up the circular referenced objects that
> will never get a count down to 0 without some outside help. It searches the
> heap looking for objects that have no references except other objects also
> in the garbage and marks those as candidates to clean out. The fact that
> these file objects are piling up means something is holding the file
> reference which also cannot be cleaned up.
>
> Are you running on Linux? If so the /proc/pid_of_web2py/fd directory using
> ls -l will show you what files by name are open to the process which might
> provide some clues to which part of your code.


Re: [web2py] Re: cron "Too many open files" regression?

2011-07-06 Thread ron_m
Maybe one possibility is if your code has classes with a __del__ method in 
them, Massimo would have better perspective on if this is a possibility. If 
a class with this method is involved in a circular reference the garbage 
collector cannot clean it up because of uncertainty of execution of the 
__del__ method. This was discussed a lot on the group a few months back. I 
believe exec also has to be involved. Do a search for __del__ in the group 
to see what was said. There were also some tools mentioned in those threads 
that help with tracking down this sort of problem.

I find in Python as soon as a file variable binding produced by open goes 
out of scope it is closed, you don't have to specifically call close on it. 
Normally objects are dropped as soon as the reference count reaches 0. The 
garbage collector was added to clean up the circular referenced objects that 
will never get a count down to 0 without some outside help. It searches the 
heap looking for objects that have no references except other objects also 
in the garbage and marks those as candidates to clean out. The fact that 
these file objects are piling up means something is holding the file 
reference which also cannot be cleaned up.

Are you running on Linux? If so the /proc/pid_of_web2py/fd directory using 
ls -l will show you what files by name are open to the process which might 
provide some clues to which part of your code.


Re: [web2py] know if a form have pass every validators

2011-07-06 Thread Richard Vézina
Forget about it...

I found the problem... There was to many things anyway.

;-)

Richard

On Wed, Jul 6, 2011 at 1:52 PM, Richard Vézina
wrote:

> I realise that it's not what I need when I just press send... Since not all
> the validators have passed when I want to my code to enter in action...
>
> I face a really bizzard issue...
>
> Here my model :
>
> db.define_table('ref_tregistry',
> Field('tregistry_id','id'),
>
> Field('vregistry_id',db.ref_vregistry,widget=SQLFORM.widgets.options.widget),
>
> Field('fnaregistry_id',db.ref_fnaregistry,widget=SQLFORM.widgets.options.widget),
> Field('tome_num','integer',
> notnull=True,
> required=True,
> represent=lambda tome_num: '%02d'%(tome_num)
> ),
> Field('t_title','text'),
> Field('att_date','date',
> notnull=True,
> requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty')),
> IS_DATE(format=T('%Y-%m-%d'),error_message=T('valid date of
> format : -MM-DD!'))],
> required=True
> ),
> Field('merged_for_validation', unique=True,
> compute=lambda r: str(r.vregistry_id) + \
> str(r.fnaregistry_id) + \
> str(r.tome_num) + \
> str(r.t_title).rstrip()
> ),
> migrate=False,
> sequence_name='ref_tregistry_tregistry_id_seq',
> format='%(tome_num)s %(title)s')
>
> As you can see there is 2 FK...
>
> Here code that is below my model :
>
> if is_empty(str(request.vars.tome_num)) != True:
> if is_empty(str(request.vars.vregistry_id)):
> tom_entry_set =
> db(db.ref_tregistry.merged_for_validation==request.vars.tome_num)
> elif is_empty(str(request.vars.fnaregistry_id)):
> tom_entry_set =
> db(db.ref_tregistry.merged_for_validation==request.vars.tome_num)
> # THERE NO WAY TO GET HERE
> else:
> tom_entry_set = db(db.ref_vregistry.merged_for_validation=='')
>
>
> It' like if vregistry_id is never empty and when I check at it it's
> empty...
>
> Richard
>
>
> On Wed, Jul 6, 2011 at 12:13 PM, Miguel Lopes wrote:
>
>> You can also use form.errors
>>
>> if form.accepts(...):
>>...
>> elif form.errors:
>>...
>> HTH,
>> Miguel
>>
>>
>> On Wed, Jul 6, 2011 at 5:08 PM, Anthony  wrote:
>>
>>> form.accepts(...) returns True if all validators pass and False otherwise
>>> -- is that what you're looking for?
>>>
>>> Anthony
>>>
>>> On Wednesday, July 6, 2011 11:43:29 AM UTC-4, Richard wrote:
>>>
 Hello,

 Is there a way I can test if form have been submit and if no validators
 have triggered?

 Thanks

 Richard

>>>
>>
>


[web2py] Re: OffTopic Google+

2011-07-06 Thread Zphen
Does anyone have a spare invitation for list-stalker like me? (only
submitted a single patch to date)

On Jul 6, 9:16 am, mikech  wrote:
> I am interested, but not anxious to add to my social load at the moment.
>  What are your impressions?
>
> Mike


Re: [web2py] Re: OffTopic Google+

2011-07-06 Thread Richard Vézina
I think that by default your friends, familly, etc. don't see in which
circle you put them... But I am not sure of that...

It's what they said : http://www.youtube.com/watch?v=ocPeAdpe_A8&NR=1 *: 43
sec*


Richard


On Wed, Jul 6, 2011 at 5:46 PM, Sebastian E. Ovide <
sebastian.ov...@gmail.com> wrote:

> yes circles is a good idea... just wondering if it possible to hide
> which group each person is part of... so that for example the "GF" wont
> complain of not being part of the "very close friends" circle... as in south
> park facebook episode :D
>
> http://www.youtube.com/watch?v=kT_cp2x0qso&feature=related
>
>
> On Wed, Jul 6, 2011 at 7:56 PM, Ross Peoples wrote:
>
>> Free, unlimited storage of photos as large as 2048x2048 and videos under
>> 15 in length is pretty awesome. This will be more than enough for most
>> people.
>>
>> @sebastian:
>>
>> The point of the circles is so that you can share information with only
>> certain groups if you want. So you could be "friends" with acquaintances so
>> that you can always have their contact information and share related
>> information with your acquaintances only. Then you could share personal
>> information with your Friends and Family circles that you wouldn't want your
>> acquaintances to know. The only way you could do such a thing with Facebook
>> is if you had a business Facebook account, and a separate account for
>> friends and families, but having two completely different accounts is a pain
>> and somewhat impractical. I'm sure the hangout feature is cool and all (I
>> haven't tried it yet), but Circles is the Facebook killing feature for me.
>>
>
>
>
> --
> Sebastian E. Ovide
>
>
>
>
>


[web2py] Re: Check

2011-07-06 Thread Anthony
That doesn't sound right. Can you reproduce the behavior?
 
Are you using CAS (
https://groups.google.com/d/topic/web2py/Qcw6B1Y89JM/discussion), or regular 
Auth?
 
Anthony

On Wednesday, July 6, 2011 3:20:37 PM UTC-4, beedge wrote:

> Thanks for responses.  Point about definition of objects in the python 
> files accepted!  Can I just check something here, as I may have the 
> wrong end of the stick... 
>
> My understanding was that the Apps are all completely independent 
> (i.e. seperate authentication etc).  However, I'm seeing an account I 
> added in the new app I created appearing in the auth tables in the 
> Welcome app...  If this is anticipated behaviour, I think I need to do 
> a bit more reading before I try anything else...



Re: [web2py] Re: OffTopic Google+

2011-07-06 Thread Sebastian E. Ovide
yes circles is a good idea... just wondering if it possible to hide
which group each person is part of... so that for example the "GF" wont
complain of not being part of the "very close friends" circle... as in south
park facebook episode :D

http://www.youtube.com/watch?v=kT_cp2x0qso&feature=related

On Wed, Jul 6, 2011 at 7:56 PM, Ross Peoples  wrote:

> Free, unlimited storage of photos as large as 2048x2048 and videos under 15
> in length is pretty awesome. This will be more than enough for most people.
>
> @sebastian:
>
> The point of the circles is so that you can share information with only
> certain groups if you want. So you could be "friends" with acquaintances so
> that you can always have their contact information and share related
> information with your acquaintances only. Then you could share personal
> information with your Friends and Family circles that you wouldn't want your
> acquaintances to know. The only way you could do such a thing with Facebook
> is if you had a business Facebook account, and a separate account for
> friends and families, but having two completely different accounts is a pain
> and somewhat impractical. I'm sure the hangout feature is cool and all (I
> haven't tried it yet), but Circles is the Facebook killing feature for me.
>



-- 
Sebastian E. Ovide


Re: [web2py] PowerTable question?

2011-07-06 Thread Jim Steil

bump

...still looking for some help and hoping not to get lost in all the 
other posts out there.  Anyone else using this tool?  Looks very 
powerful but I'm having trouble with a couple of basic issues.


If anyone knows of a better place to post my question, I'm all ears...

-Jim

On 7/5/2011 4:55 PM, Jim Steil wrote:
Not sure if this is the right place to ask questions about PowerTable, 
but I have 3.


1.  Where to find the documentation, can't seem to locate it at 
http://powertable.blouweb.com/
2.  I want to enable clicking on a row to navigate to a URL containing 
the record key field.  Can't seem to find where to put the JS to do so
3.  I want to have my table taller than the default and have set the 
default number of rows to display at one time to 20.


Again, not sure if this is the right place to ask for help.  Just 
hoping to find some answers.


-Jim


[web2py] Re: requires_permission example

2011-07-06 Thread pbreit
You can do it with code:

1.

auth.add_permission(group_id, 'name', 'object', record_id)

gives permission "name" (user defined) on the object "object" (also user 
defined) to members of the group group_id. If "object" is a tablename then 
the permission can refer to the entire table by setting record_id to a value 
of zero, or the permission can refer to a specific record by specifying a 
record_id value greater than zero. When giving permissions on tables, it is 
common to use a permission name in the set ('create', 'read', 'update', 
'delete', 'select') since these permissions are understood and can be 
enforced by CRUD.

Or in appadmin:
http://127.0.0.1:8000/appadmin/insert/db/auth_permission


[web2py] requires_permission example

2011-07-06 Thread Tim Korb
I'm trying to figure out this example from the book of 
requires_permission...

@auth.requires_permission('add', 'number')
def add(a, b):
return a + b

def function_seven():
return add(3, 4)

I put this code into controllers/default.py.  What additional auth db 
entries do I need to make this example work?  I guess "add" is the name of a 
permission that must be assigned to some group, but what is "number"? 
 (Currently, I get "Not authorized, access denied" when I try to connect to 
the page.)


[web2py] Check

2011-07-06 Thread beedge
Thanks for responses.  Point about definition of objects in the python
files accepted!  Can I just check something here, as I may have the
wrong end of the stick...

My understanding was that the Apps are all completely independent
(i.e. seperate authentication etc).  However, I'm seeing an account I
added in the new app I created appearing in the auth tables in the
Welcome app...  If this is anticipated behaviour, I think I need to do
a bit more reading before I try anything else...


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Anthony
Do you have:
 
auth.settings.registration_requires_verification = True
 
somewhere? If so, remove that line or set it to False. That attempts to send 
a verification email to the user's email address (which is failing and 
causing the error), which I assume you don't need given that your 
registration is via invitation only.
 
Anthony

On Wednesday, July 6, 2011 2:39:27 PM UTC-4, Luis Goncalves wrote:

>
> Both with Massimo's
>
>   auth.settings.table_user.email.default = registrant.email
>   auth.settings.table_user.email.writable=False
>
>   form=auth.register()
>
> and with your 
>
>   db[auth.settings.table_user_name].email.writable=False
>   db[auth.settings.table_user_name].email.default=registrant.email
>   
>   form=auth.register()
>
> I get the error
>
> Exception: Target receiver address not specified
>
> at the line ofform=auth.register()
>
>
> For reference, the entire block (with error handling removed for clarity) 
> is:
>
>   def user():
>   
>   if request.args(0)=='register':
>   
>   registrant = db( db.registrant.token == request.vars.token 
> ).select().first()
>   
>   db[auth.settings.table_user_name].email.writable=False
>   db[auth.settings.table_user_name].email.default=registrant.email
>   
>   form=auth.register()
>   
>   return dict(form=form)
>
> return dict(form=auth())
>
>

[web2py] redirect to profile if first time login

2011-07-06 Thread Nicolas Palumbo
I'm currently using ldap to auth with ldap_auth module of web2py.
Currently if you are successful to login, are automatically redirected
to index page.
Which  happens the first time the user log in to the system as well.
I'd like to detect if it is the first time for a user to log into the
system and then redirect to profile edition.
Any ideas?

I was advised to to this:
auth.settings.register_next = URL('defaul', 'user', args=['profile'])
But is not working, I think is because users are not registering. They
just log in.

Thanks in advance,
Nico


Re: [web2py] multiselect filter

2011-07-06 Thread Richard Vézina
Yes it is a other option for multiselect.

;-)

Richard

On Wed, Jul 6, 2011 at 2:45 PM, Nicolas Palumbo  wrote:

> I ended up using this widget, which is more intuitive for a big list:
> http://www.quasipartikel.at/multiselect/
>
> On Wed, Jul 6, 2011 at 6:08 PM, Richard Vézina
>  wrote:
> > http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/
> > If you use this plugin I think it will work... See seconde plugin demo
> > dropbox in the page...
> > Richard
> >
> > On Wed, Jul 6, 2011 at 10:59 AM, Nicolas Palumbo 
> > wrote:
> >>
> >> Hi, is it possible to apply filtering in a multiselect control created
> >> with list:refereces.
> >> I mean I have the list of options, which is quite big.
> >>
> >> ---
> >> opt1
> >> opt2
> >>
> >> ---
> >>
> >> I'd like to be able to see a shortened version according to the
> >> content of a filter field (textbox or so), but at the same time keep
> >> the tracks of what is selected.
> >>
> >> Thanks in advance,
> >> Nico
> >
> >
>


[web2py] Re: Field type

2011-07-06 Thread mart
well, i think so but, even if a field is set to 'string', and a script
receives something comma delimited, DAL will will want to treat it as
a list.

so doing x.type takes me half the way, then i need to check if a list
wasn't inserted into the record instead (most of the time i get a
string, but sometime I get a list)

Mart :)



On Jul 6, 2:20 pm, Anthony  wrote:
> Doesn't db.myTable.myField.type work? Or am I missing something?
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, July 6, 2011 12:59:54 PM UTC-4, mart wrote:
> > almost :) i'm looking to guess the field types. for example, at the
> > cmd line i can use a quick and dirty helper like this:
>
> > -table myTable fields=id,name,value
>
> > this displays a nice ascii table but, the fields are comma delimited
> > so if the returned field is a list (also comma delimited), the table
> > isn't very pretty anymore (because it separates the field items with
> > commas :))
>
> > so if I can get the script to guess the field type, i can replace the
> > comma with a line break (which would just extend the table field in
> > height)
>
> > thanks,
> > Mart :)
>
> > On Jul 6, 12:48 pm, Anthony  wrote:
> > > db.tables is a list of the names of the tables in db, and
> > > db.tablename.fields is a list of the names of the fields in db.tablename.
> > Is
> > > that what you're looking for?
>
> > > Anthony
>
> > > On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote:
> > > > hi,
>
> > > > question:
>
> > > > how could I guess the field in something like an interactive shell?
>
> > > > i assume, I have to specify db.tableName.filedName?
>
> > > > is there something like db.myTable.myField.type?
>
> > > > thanks,
> > > > Mart :)
>
> > > > On Jul 4, 12:11 pm, mart  wrote:
> > > > > ah ha! thank you very much! :)
>
> > > > > On Jul 4, 11:46 am, Massimo Di Pierro 
> > > > > wrote:
>
> > > > > > f = Field('myString')
>
> > > > > > print f.type
> > > > > > if isinstance(f.type,str) and f.type=='string': ..
> > > > > > if isinstance(f.type,str) and f.type=='text': ..
> > > > > > if isinstance(f.type,str) and f.type=='upload': ..
> > > > > > if isinstance(f.type,str) and f.type=='blob': ..
> > > > > > ..
> > > > > > if not isinstance(f.type,str): # custom field probably
>
> > > > > > On Jul 4, 10:17 am, mart  wrote:
>
> > > > > > > woops, sorry
>
> > > > > > > so something like:
>
> > > > > > > if isinstance(Field,list): blala
> > > > > > > elif isinstance(Field,str): blala
> > > > > > > else:blabla
>
> > > > > > > thanks,
> > > > > > > Mart :)
>
> > > > > > > On Jul 4, 11:15 am, mart  wrote:
>
> > > > > > > > Can dal guess field type even if not explicit?
>
> > > > > > > > I.e. if I have a Field like Field('myString') but a script ends
> > up
> > > > > > > > inserting something that looks like a list, how can I have a
> > > > default
> > > > > > > > check?
>
> > > > > > > > something like:


Re: [web2py] Re: OffTopic Google+

2011-07-06 Thread Ross Peoples
Free, unlimited storage of photos as large as 2048x2048 and videos under 15 
in length is pretty awesome. This will be more than enough for most people.

@sebastian:

The point of the circles is so that you can share information with only 
certain groups if you want. So you could be "friends" with acquaintances so 
that you can always have their contact information and share related 
information with your acquaintances only. Then you could share personal 
information with your Friends and Family circles that you wouldn't want your 
acquaintances to know. The only way you could do such a thing with Facebook 
is if you had a business Facebook account, and a separate account for 
friends and families, but having two completely different accounts is a pain 
and somewhat impractical. I'm sure the hangout feature is cool and all (I 
haven't tried it yet), but Circles is the Facebook killing feature for me.


[web2py] Re: Command-line support

2011-07-06 Thread (m)
Massimo, thanks for the post -- it clarifies some of what you said on
09 Nov 2010. I actually revived this thread to see if anyone had
collected these under one interface, e.g.:

web2py_manage --newapp=APPNAME
  Makes a new directory applications/APPNAME and copies scaffolding
there.

web2py_manage --newcontroller=CONTROLLER_NAME [--appname=APPNAME]
  Makes a new file CONTROLLER_NAME.py in applications/$APPNAME/
controllers
  (or . if APPNAME isn't given) and places template code in the new
  file consisting of an index action.
  Makes a new dir applications/APPNAME/views/CONTROLLER_NAME and
places
  a template index.html file in it.

web2py_manage --newmodel=MODEL_NAME [--appname APPNAME]
  Makes a new file MODEL_NAME.py in applications/APPNAME/models
  (or . if APPNAME isn't given) and maybe sticks some template code in
there
  with CRUD and authorization imports.

etc.

I can bash something together in an evening (or py it out as a
learning exercise), but if the wheel already exists ...


Re: [web2py] multiselect filter

2011-07-06 Thread Nicolas Palumbo
I ended up using this widget, which is more intuitive for a big list:
http://www.quasipartikel.at/multiselect/

On Wed, Jul 6, 2011 at 6:08 PM, Richard Vézina
 wrote:
> http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/
> If you use this plugin I think it will work... See seconde plugin demo
> dropbox in the page...
> Richard
>
> On Wed, Jul 6, 2011 at 10:59 AM, Nicolas Palumbo 
> wrote:
>>
>> Hi, is it possible to apply filtering in a multiselect control created
>> with list:refereces.
>> I mean I have the list of options, which is quite big.
>>
>> ---
>> opt1
>> opt2
>>
>> ---
>>
>> I'd like to be able to see a shortened version according to the
>> content of a filter field (textbox or so), but at the same time keep
>> the tracks of what is selected.
>>
>> Thanks in advance,
>> Nico
>
>


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves

Both with Massimo's

  auth.settings.table_user.email.default = registrant.email
  auth.settings.table_user.email.writable=False
   
  form=auth.register()

and with your 

  db[auth.settings.table_user_name].email.writable=False
  db[auth.settings.table_user_name].email.default=registrant.email
  
  form=auth.register()

I get the error

Exception: Target receiver address not specified

at the line ofform=auth.register()


For reference, the entire block (with error handling removed for clarity) 
is:

  def user():
  
  if request.args(0)=='register':
  
  registrant = db( db.registrant.token == request.vars.token 
).select().first()
  
  db[auth.settings.table_user_name].email.writable=False
  db[auth.settings.table_user_name].email.default=registrant.email
  
  form=auth.register()
  
  return dict(form=form)

return dict(form=auth())



[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Anthony
On Wednesday, July 6, 2011 2:04:26 PM UTC-4, Luis Goncalves wrote: 
>
>   db.table_user.email.writable=False # gives error
>
 
I think this should be db.auth_user, not db.table_user. Note, the name of 
the auth user table (which defaults to 'auth_user') is stored in 
auth.settings.table_user_name, so you could also do:
 
db[auth.settings.table_user_name].email.writable=False
 
 
Anthony


[web2py] Re: Field type

2011-07-06 Thread Anthony
Doesn't db.myTable.myField.type work? Or am I missing something?
 
Anthony

On Wednesday, July 6, 2011 12:59:54 PM UTC-4, mart wrote:

> almost :) i'm looking to guess the field types. for example, at the 
> cmd line i can use a quick and dirty helper like this: 
>
> -table myTable fields=id,name,value 
>
> this displays a nice ascii table but, the fields are comma delimited 
> so if the returned field is a list (also comma delimited), the table 
> isn't very pretty anymore (because it separates the field items with 
> commas :)) 
>
> so if I can get the script to guess the field type, i can replace the 
> comma with a line break (which would just extend the table field in 
> height) 
>
> thanks, 
> Mart :) 
>
> On Jul 6, 12:48 pm, Anthony  wrote: 
> > db.tables is a list of the names of the tables in db, and 
> > db.tablename.fields is a list of the names of the fields in db.tablename. 
> Is 
> > that what you're looking for? 
> > 
> > Anthony 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote: 
> > > hi, 
> > 
> > > question: 
> > 
> > > how could I guess the field in something like an interactive shell? 
> > 
> > > i assume, I have to specify db.tableName.filedName? 
> > 
> > > is there something like db.myTable.myField.type? 
> > 
> > > thanks, 
> > > Mart :) 
> > 
> > > On Jul 4, 12:11 pm, mart  wrote: 
> > > > ah ha! thank you very much! :) 
> > 
> > > > On Jul 4, 11:46 am, Massimo Di Pierro  
> > > > wrote: 
> > 
> > > > > f = Field('myString') 
> > 
> > > > > print f.type 
> > > > > if isinstance(f.type,str) and f.type=='string': .. 
> > > > > if isinstance(f.type,str) and f.type=='text': .. 
> > > > > if isinstance(f.type,str) and f.type=='upload': .. 
> > > > > if isinstance(f.type,str) and f.type=='blob': .. 
> > > > > .. 
> > > > > if not isinstance(f.type,str): # custom field probably 
> > 
> > > > > On Jul 4, 10:17 am, mart  wrote: 
> > 
> > > > > > woops, sorry 
> > 
> > > > > > so something like: 
> > 
> > > > > > if isinstance(Field,list): blala 
> > > > > > elif isinstance(Field,str): blala 
> > > > > > else:blabla 
> > 
> > > > > > thanks, 
> > > > > > Mart :) 
> > 
> > > > > > On Jul 4, 11:15 am, mart  wrote: 
> > 
> > > > > > > Can dal guess field type even if not explicit? 
> > 
> > > > > > > I.e. if I have a Field like Field('myString') but a script ends 
> up 
> > > > > > > inserting something that looks like a list, how can I have a 
> > > default 
> > > > > > > check? 
> > 
> > > > > > > something like:



Re: [web2py] multiselect filter

2011-07-06 Thread Richard Vézina
http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/

If you use this plugin I think it will work... See seconde plugin demo
dropbox in the page...

Richard


On Wed, Jul 6, 2011 at 10:59 AM, Nicolas Palumbo wrote:

> Hi, is it possible to apply filtering in a multiselect control created
> with list:refereces.
> I mean I have the list of options, which is quite big.
>
> ---
> opt1
> opt2
>
> ---
>
> I'd like to be able to see a shortened version according to the
> content of a filter field (textbox or so), but at the same time keep
> the tracks of what is selected.
>
> Thanks in advance,
> Nico
>


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Massimo Di Pierro
This should do it:

def user():
  if request.args(0)=='register':
  registrant = db(db.registrant.token ==
request.vars.token).select().first() or redirect(URL('error'))
  db.auth_user.email.writable=False # gives error
  db.auth_user.email.default=registrant.email
 return dict(form=form)


On Jul 6, 1:04 pm, Luis Goncalves  wrote:
> Good point!
>
> Unfortunately, I am not expert enough to understand how to do this in my
> case, because I am using the form=auth.register().
>
> Wouldn't I have to do what you suggest inside Auth.register ?
>
> (for an explanation of why I am doing this, see:  
> https://groups.google.com/forum/#!topic/web2py/O3O6J5FgXjU)
>
>   def user():
>
>       if request.args(0)=='register':
>
>           db.table_user.email.writable=False # gives error
>           form=auth.register()
>
>           registrant = db( db.registrant.token == request.vars.token
> ).select().first()
>
>           form.element(_name='email').update(_value=registrant.email)
>
>           form.element(_name='email')['_readonly']=True
>
>           return dict(form=form)
>
> Thanks!!
> Luis.


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Luis Goncalves

Good point!

Unfortunately, I am not expert enough to understand how to do this in my 
case, because I am using the form=auth.register().

Wouldn't I have to do what you suggest inside Auth.register ?

(for an explanation of why I am doing this, see:  
https://groups.google.com/forum/#!topic/web2py/O3O6J5FgXjU )


  def user():
  
  if request.args(0)=='register':
  
  db.table_user.email.writable=False # gives error
  form=auth.register()

  registrant = db( db.registrant.token == request.vars.token 
).select().first()
  
  form.element(_name='email').update(_value=registrant.email)
  
  form.element(_name='email')['_readonly']=True
  
  return dict(form=form)

Thanks!!
Luis.


Re: [web2py] know if a form have pass every validators

2011-07-06 Thread Richard Vézina
I realise that it's not what I need when I just press send... Since not all
the validators have passed when I want to my code to enter in action...

I face a really bizzard issue...

Here my model :

db.define_table('ref_tregistry',
Field('tregistry_id','id'),

Field('vregistry_id',db.ref_vregistry,widget=SQLFORM.widgets.options.widget),

Field('fnaregistry_id',db.ref_fnaregistry,widget=SQLFORM.widgets.options.widget),
Field('tome_num','integer',
notnull=True,
required=True,
represent=lambda tome_num: '%02d'%(tome_num)
),
Field('t_title','text'),
Field('att_date','date',
notnull=True,
requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty')),
IS_DATE(format=T('%Y-%m-%d'),error_message=T('valid date of
format : -MM-DD!'))],
required=True
),
Field('merged_for_validation', unique=True,
compute=lambda r: str(r.vregistry_id) + \
str(r.fnaregistry_id) + \
str(r.tome_num) + \
str(r.t_title).rstrip()
),
migrate=False,
sequence_name='ref_tregistry_tregistry_id_seq',
format='%(tome_num)s %(title)s')

As you can see there is 2 FK...

Here code that is below my model :

if is_empty(str(request.vars.tome_num)) != True:
if is_empty(str(request.vars.vregistry_id)):
tom_entry_set =
db(db.ref_tregistry.merged_for_validation==request.vars.tome_num)
elif is_empty(str(request.vars.fnaregistry_id)):
tom_entry_set =
db(db.ref_tregistry.merged_for_validation==request.vars.tome_num)
# THERE NO WAY TO GET HERE
else:
tom_entry_set = db(db.ref_vregistry.merged_for_validation=='')


It' like if vregistry_id is never empty and when I check at it it's empty...

Richard


On Wed, Jul 6, 2011 at 12:13 PM, Miguel Lopes  wrote:

> You can also use form.errors
>
> if form.accepts(...):
>...
> elif form.errors:
>...
> HTH,
> Miguel
>
>
> On Wed, Jul 6, 2011 at 5:08 PM, Anthony  wrote:
>
>> form.accepts(...) returns True if all validators pass and False otherwise
>> -- is that what you're looking for?
>>
>> Anthony
>>
>> On Wednesday, July 6, 2011 11:43:29 AM UTC-4, Richard wrote:
>>
>>> Hello,
>>>
>>> Is there a way I can test if form have been submit and if no validators
>>> have triggered?
>>>
>>> Thanks
>>>
>>> Richard
>>>
>>
>


[web2py] Re: Command-line support

2011-07-06 Thread Massimo Di Pierro
The fact is, you can already do very much everything form the shell:

create an app

cd application
mkdir myapp
cp -r welcome/* myapp

delete an app

rm -r applications

copy a plugin

cd ~/web2py
ccpcplugin.py plugin_name app_source app_target

install a remote app or remote plugin

cd applications/myapp
tar zxvf path/to/web2py.app.name.w2p

etc.

etc. The web2py/gluon/admin.py has API to access equivalent
functionalities programmatically.
I am not sure what else is needed. Can you give me an example?

Massimo


On Jul 6, 11:36 am, "(m)"  wrote:
> I am wondering if this discussion ended up going anywhere. As a newbie
> webapp developer (but not a newbie programmer), the only thing I might add
> to what blackthorne has already said is that I'm finding it easier to
> understand what's going on and what's where by interacting with my
> filesystem and writing stuff in a conventional IDE. (Alternately, the Web
> interface could be redesigned to be more IDE-ish ... but that's another
> discussion.) If I could do all the project management stuff from the command
> line (or commands I weld into my IDE) I would.


[web2py] Re: Command-line support

2011-07-06 Thread (m)
I am wondering if this discussion ended up going anywhere. As a newbie 
webapp developer (but not a newbie programmer), the only thing I might add 
to what blackthorne has already said is that I'm finding it easier to 
understand what's going on and what's where by interacting with my 
filesystem and writing stuff in a conventional IDE. (Alternately, the Web 
interface could be redesigned to be more IDE-ish ... but that's another 
discussion.) If I could do all the project management stuff from the command 
line (or commands I weld into my IDE) I would.



[web2py] Re: Field type

2011-07-06 Thread mart
this test worked (yeah, i asked the question too hastily again ;) )

for item in self.db[table].fields:
if isinstance(self.db[table][item].type,str) \
and self.db[table][item].type=='string':
print 'field is string: {0}'.format(self.db[table][item])


returned:

field is string: cumulativeProperties.uuid
field is string: cumulativeProperties.name
field is string: cumulativeProperties.value
field is string: cumulativeProperties.tag
field is string: cumulativeProperties.cmdname


thanks,
Mart :)


On Jul 6, 12:59 pm, mart  wrote:
> almost :) i'm looking to guess the field types. for example, at the
> cmd line i can use a quick and dirty helper like this:
>
> -table myTable fields=id,name,value
>
> this displays a nice ascii table but, the fields are comma delimited
> so if the returned field is a list (also comma delimited), the table
> isn't very pretty anymore (because it separates the field items with
> commas :))
>
> so if I can get the script to guess the field type, i can replace the
> comma with a line break (which would just extend the table field in
> height)
>
> thanks,
> Mart :)
>
> On Jul 6, 12:48 pm, Anthony  wrote:
>
>
>
>
>
>
>
> > db.tables is a list of the names of the tables in db, and
> > db.tablename.fields is a list of the names of the fields in db.tablename. Is
> > that what you're looking for?
>
> > Anthony
>
> > On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote:
> > > hi,
>
> > > question:
>
> > > how could I guess the field in something like an interactive shell?
>
> > > i assume, I have to specify db.tableName.filedName?
>
> > > is there something like db.myTable.myField.type?
>
> > > thanks,
> > > Mart :)
>
> > > On Jul 4, 12:11 pm, mart  wrote:
> > > > ah ha! thank you very much! :)
>
> > > > On Jul 4, 11:46 am, Massimo Di Pierro 
> > > > wrote:
>
> > > > > f = Field('myString')
>
> > > > > print f.type
> > > > > if isinstance(f.type,str) and f.type=='string': ..
> > > > > if isinstance(f.type,str) and f.type=='text': ..
> > > > > if isinstance(f.type,str) and f.type=='upload': ..
> > > > > if isinstance(f.type,str) and f.type=='blob': ..
> > > > > ..
> > > > > if not isinstance(f.type,str): # custom field probably
>
> > > > > On Jul 4, 10:17 am, mart  wrote:
>
> > > > > > woops, sorry
>
> > > > > > so something like:
>
> > > > > > if isinstance(Field,list): blala
> > > > > > elif isinstance(Field,str): blala
> > > > > > else:blabla
>
> > > > > > thanks,
> > > > > > Mart :)
>
> > > > > > On Jul 4, 11:15 am, mart  wrote:
>
> > > > > > > Can dal guess field type even if not explicit?
>
> > > > > > > I.e. if I have a Field like Field('myString') but a script ends up
> > > > > > > inserting something that looks like a list, how can I have a
> > > default
> > > > > > > check?
>
> > > > > > > something like:


Re: [web2py] Re: OffTopic Google+

2011-07-06 Thread Vasile Ermicioi
http://picasa.google.com/support/bin/answer.py?answer=1224181

If you've signed up for Google+

Photos up to 2048 x 2048 pixels and videos up to 15 minutes won't count
towards your free storage.
If you haven't signed up for Google+

Photos up to 800 x 800 pixels and videos up to 15 minutes won't count
towards your free storage.


[web2py] Re: Field type

2011-07-06 Thread mart
almost :) i'm looking to guess the field types. for example, at the
cmd line i can use a quick and dirty helper like this:

-table myTable fields=id,name,value

this displays a nice ascii table but, the fields are comma delimited
so if the returned field is a list (also comma delimited), the table
isn't very pretty anymore (because it separates the field items with
commas :))

so if I can get the script to guess the field type, i can replace the
comma with a line break (which would just extend the table field in
height)

thanks,
Mart :)

On Jul 6, 12:48 pm, Anthony  wrote:
> db.tables is a list of the names of the tables in db, and
> db.tablename.fields is a list of the names of the fields in db.tablename. Is
> that what you're looking for?
>
> Anthony
>
>
>
>
>
>
>
> On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote:
> > hi,
>
> > question:
>
> > how could I guess the field in something like an interactive shell?
>
> > i assume, I have to specify db.tableName.filedName?
>
> > is there something like db.myTable.myField.type?
>
> > thanks,
> > Mart :)
>
> > On Jul 4, 12:11 pm, mart  wrote:
> > > ah ha! thank you very much! :)
>
> > > On Jul 4, 11:46 am, Massimo Di Pierro 
> > > wrote:
>
> > > > f = Field('myString')
>
> > > > print f.type
> > > > if isinstance(f.type,str) and f.type=='string': ..
> > > > if isinstance(f.type,str) and f.type=='text': ..
> > > > if isinstance(f.type,str) and f.type=='upload': ..
> > > > if isinstance(f.type,str) and f.type=='blob': ..
> > > > ..
> > > > if not isinstance(f.type,str): # custom field probably
>
> > > > On Jul 4, 10:17 am, mart  wrote:
>
> > > > > woops, sorry
>
> > > > > so something like:
>
> > > > > if isinstance(Field,list): blala
> > > > > elif isinstance(Field,str): blala
> > > > > else:blabla
>
> > > > > thanks,
> > > > > Mart :)
>
> > > > > On Jul 4, 11:15 am, mart  wrote:
>
> > > > > > Can dal guess field type even if not explicit?
>
> > > > > > I.e. if I have a Field like Field('myString') but a script ends up
> > > > > > inserting something that looks like a list, how can I have a
> > default
> > > > > > check?
>
> > > > > > something like:


Re: [web2py] easy way to validate a list of emails?

2011-07-06 Thread Luis Goncalves
Excellent!  Works perfectly!!  Also a great lesson in how to extend the set 
of web2py form validators!

Thank you, Bruno!!!  Obrigado!!!
Luis.


Re: [web2py] Re: OffTopic Google+

2011-07-06 Thread Sebastian E. Ovide
I'm not very sure about the effects that could have including some person to
the "Acquaintances" circle rather than to the "Friends" circle

On Wed, Jul 6, 2011 at 12:52 PM, Ross Peoples wrote:

> I have tried it. I like it better than Facebook, especially because of its
> commitment to privacy. The circles feature is great. I think most people
> don't friend their bosses, coworkers, and business acquaintances of Facebook
> because they don't want their personal lives to be exposed to those people.
> However, with Google+, you can friend everyone you know and only share your
> personal weekend drunken parties with your Friends (and maybe Family)
> circle.
>
> It's still missing a few key features (it is in beta after all), like the
> ability to write on someone's wall or send them a private message, but for
> the most part, it's pretty nice. I am really, REALLY pulling for Google
> here, as I hate Facebook.
>



-- 
Sebastian E. Ovide


[web2py] Re: Field type

2011-07-06 Thread Anthony
db.tables is a list of the names of the tables in db, and 
db.tablename.fields is a list of the names of the fields in db.tablename. Is 
that what you're looking for?
 
Anthony

On Wednesday, July 6, 2011 12:27:09 PM UTC-4, mart wrote:

> hi, 
>
> question: 
>
> how could I guess the field in something like an interactive shell? 
>
> i assume, I have to specify db.tableName.filedName? 
>
> is there something like db.myTable.myField.type? 
>
> thanks, 
> Mart :) 
>
> On Jul 4, 12:11 pm, mart  wrote: 
> > ah ha! thank you very much! :) 
> > 
> > On Jul 4, 11:46 am, Massimo Di Pierro  
> > wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > f = Field('myString') 
> > 
> > > print f.type 
> > > if isinstance(f.type,str) and f.type=='string': .. 
> > > if isinstance(f.type,str) and f.type=='text': .. 
> > > if isinstance(f.type,str) and f.type=='upload': .. 
> > > if isinstance(f.type,str) and f.type=='blob': .. 
> > > .. 
> > > if not isinstance(f.type,str): # custom field probably 
> > 
> > > On Jul 4, 10:17 am, mart  wrote: 
> > 
> > > > woops, sorry 
> > 
> > > > so something like: 
> > 
> > > > if isinstance(Field,list): blala 
> > > > elif isinstance(Field,str): blala 
> > > > else:blabla 
> > 
> > > > thanks, 
> > > > Mart :) 
> > 
> > > > On Jul 4, 11:15 am, mart  wrote: 
> > 
> > > > > Can dal guess field type even if not explicit? 
> > 
> > > > > I.e. if I have a Field like Field('myString') but a script ends up 
> > > > > inserting something that looks like a list, how can I have a 
> default 
> > > > > check? 
> > 
> > > > > something like:



[web2py] Re: Field type

2011-07-06 Thread mart
hi,

question:

how could I guess the field in something like an interactive shell?

i assume, I have to specify db.tableName.filedName?

is there something like db.myTable.myField.type?

thanks,
Mart :)

On Jul 4, 12:11 pm, mart  wrote:
> ah ha! thank you very much! :)
>
> On Jul 4, 11:46 am, Massimo Di Pierro 
> wrote:
>
>
>
>
>
>
>
> > f = Field('myString')
>
> > print f.type
> > if isinstance(f.type,str) and f.type=='string': ..
> > if isinstance(f.type,str) and f.type=='text': ..
> > if isinstance(f.type,str) and f.type=='upload': ..
> > if isinstance(f.type,str) and f.type=='blob': ..
> > ..
> > if not isinstance(f.type,str): # custom field probably
>
> > On Jul 4, 10:17 am, mart  wrote:
>
> > > woops, sorry
>
> > > so something like:
>
> > > if isinstance(Field,list): blala
> > > elif isinstance(Field,str): blala
> > > else:blabla
>
> > > thanks,
> > > Mart :)
>
> > > On Jul 4, 11:15 am, mart  wrote:
>
> > > > Can dal guess field type even if not explicit?
>
> > > > I.e. if I have a Field like Field('myString') but a script ends up
> > > > inserting something that looks like a list, how can I have a default
> > > > check?
>
> > > > something like:


Re: [web2py] know if a form have pass every validators

2011-07-06 Thread Miguel Lopes
You can also use form.errors

if form.accepts(...):
   ...
elif form.errors:
   ...
HTH,
Miguel

On Wed, Jul 6, 2011 at 5:08 PM, Anthony  wrote:

> form.accepts(...) returns True if all validators pass and False otherwise
> -- is that what you're looking for?
>
> Anthony
>
> On Wednesday, July 6, 2011 11:43:29 AM UTC-4, Richard wrote:
>
>> Hello,
>>
>> Is there a way I can test if form have been submit and if no validators
>> have triggered?
>>
>> Thanks
>>
>> Richard
>>
>


Re: [web2py] know if a form have pass every validators

2011-07-06 Thread Anthony
form.accepts(...) returns True if all validators pass and False otherwise -- 
is that what you're looking for?
 
Anthony

On Wednesday, July 6, 2011 11:43:29 AM UTC-4, Richard wrote:

> Hello, 
>
> Is there a way I can test if form have been submit and if no validators 
> have triggered?
>
> Thanks
>
> Richard
>


[web2py] know if a form have pass every validators

2011-07-06 Thread Richard Vézina
Hello,

Is there a way I can test if form have been submit and if no validators have
triggered?

Thanks

Richard


[web2py] Re: easy way to validate a list of emails?

2011-07-06 Thread pbreit
Would IS_IN_SET() work?

[web2py] Re: talks

2011-07-06 Thread pbreit
Here we go. Looks good. Cool that it's at Yelp, too.

   *What*: Double Feature: Web2Py + Speeding up Dev Cycles with Tools for 
Django & others  
*When*: Wednesday, July 13, 2011 6:30 PM

*Where*: Yelp
706 Mission Street 
San Francisco, CA 94103


[web2py] "Movie not loaded..." problem with flash

2011-07-06 Thread Miguel Lopes
It is unlikely that this is web2py related, but I'm about to go crazy with
this one. But I guess it's such a general thing someone must know what is
going on.

I'm using different uploaded media, such as files, images and flash files
(.swf files). I can display images without problem, but not flash. Here's my
view template:


  
  



The movie does not load and the flash player menu states "Movie not
loaded...". However this should work, since it works fine with static files:


  
  


Any tips?
Miguel


Re: [web2py] Re: Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
Humm,

Nice. Yes, closures are enough, and cleaner too.
Is routes OK for production mode?
Txs,
Miguel

On Wed, Jul 6, 2011 at 3:54 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Jonathan is right. Here is a simple way around.
>
> Create a single controller called dynamical. use request.args(0) to
> parse the name of one of the dynamical actions and remap
>
> def dynamical():
> actionname, request.args[:] = request.args(0), request.args[1:]
> # call actionname and pass request.args and request.vars
>
> use routes to remove the 'dynamical/' part form the URL.
>
> This allows you to do what you want without necessarily meta-
> programming.
>
> On Jul 6, 9:35 am, Miguel Lopes  wrote:
> > Thanks. In conjunction with routes could supply a solution (shortening
> the
> > urls).
> > I think I should rethink the payoff (see my reply to Massimo regarding my
> > goals).
> > Thanks,
> > Miguel
> >
> >
> >
> >
> >
> >
> >
> > On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell 
> wrote:
> > > On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
> >
> > > I'm experimenting with dynamically generating functions, aka 'actions'
> in
> > > controllers. However, I've been unsuccessful. I can use exec and
> closures
> > > successfully in regular Python code, but I can't make it work with
> web2py.
> > > Any thoughts on how to achieve this?
> >
> > > web2py finds functions by reading the (static) controller file itself.
> See
> > > gluon.compileapp.run_controller_in, in particular this line:
> >
> > > exposed = regex_expose.findall(code)
> >
> > > So, no dynamically generated controller actions, at least not directly.
> >
> > > I haven't given this much thought, but one way you might accomplish the
> > > same effect would be to push the dynamic function name down one level
> in the
> > > URL, something like:http://domain.com/app/dynamic/index/function/...
> >
> > > ...where 'dynamic' is the controller with dynamic functions, and index
> is a
> > > (static) function that calls function dynamically. You might optimize
> the
> > > lookup function to extract only the one desired function from your page
> > > table.
> >
> > > Depending on your overall URL structure, you could rewrite the URLs to
> > > shorten them up.
> >
> > > A closure example - FAILS in web2py:
> > > top_pages = db(db.page.id > 0).select()
> > > def add_actions(top_pages):
> > > for page in top_pages:
> > > def inneraction(msg):
> > > sidebar = None
> > > return dict(message=msg, sidebar=sidebar)
> > > inneraction.__name__ = page.link_name
> > > globals()[page.link_name] = inneraction
> >
> > > add_actions(top_pages)
> >
> > > A exec example - FAILS in web2py:
> >
> > > ACTION_TEMPLATE = """
> > >  def NEW_ACTION():
> > > sidebar = None
> > > return dict(message='s', sidebar=sidebar)
> > >  """
> > > top_pages = db(db.page.id > 0).select()
> > > def makePages(pages):
> > > for page in top_pages:
> > > exec ACTION_TEMPLATE
> > > NEW_ACTION.__name__ = page.link_name
> > > globals()[page.link_name] = NEW_ACTION
> >
> > > makePages(pages)
> >
> > > Miguel
>


[web2py] multiselect filter

2011-07-06 Thread Nicolas Palumbo
Hi, is it possible to apply filtering in a multiselect control created
with list:refereces.
I mean I have the list of options, which is quite big.

---
opt1
opt2

---

I'd like to be able to see a shortened version according to the
content of a filter field (textbox or so), but at the same time keep
the tracks of what is selected.

Thanks in advance,
Nico


[web2py] Re: cron "Too many open files" regression?

2011-07-06 Thread Massimo Di Pierro
Please keep us posted.

Massimo

On Jul 6, 9:31 am, John Duddy  wrote:
> It was my understanding that Python's GC frees any resources not explicitly
> freed, and cron runs jobs in a try/except/finally block and rolls back any
> uncommitted transactions.
>
> I have reproduced the issue with the three running sequentially, and in
> every case, the logs indicate that my functions exit, meaning that the
> rollback (I'm committing) and GC actions should occur, or at the very least,
> the OS should close/release stuff when the crom process exits.
>
> Hmmm.. This is going to be interesting to track down.
>
> On Wed, Jul 6, 2011 at 5:56 AM, Massimo Di Pierro <
>
>
>
>
>
>
>
>
>
> massimo.dipie...@gmail.com> wrote:
> > Yes that is the problem wit cron issue. If one of the processes locks
> > a resource, cron does not know about it and keeps spawning processes
> > as scheduled. The new processes find the resource locked and freeze of
> > crash but use ram. This is not a bug because cron is not supposed to
> > know what the tasks do. This is a general logic problem with cron.
> > Using one single background process that loops and sleeps is much
> > safer.
>
> > Massimo
>
> > On Jul 6, 1:34 am, ron_m  wrote:
> > > Sounds like some kind of race condition between the cron scripts because
> > it
> > > doesn't happen every time. Is there any chance the 3 cron scripts are
> > > dependent on each other in some way such as a file passed between or
> > sharing
> > > a database. If there is any relationship between the cron scripts would
> > it
> > > be possible to make a single script that just runs the 3 scripts
> > > sequentially and use that as your cron script. Do the scripts access the
> > > database and the database happens to be SQLite which locks for the
> > duration
> > > of an access/
>
> > > Without seeing some code and more details determining the cause is a
> > guess.
>
> > > Ron
>
> --
> John Duddy
> jdu...@gmail.com


[web2py] Re: Metaprogramming in controller

2011-07-06 Thread Massimo Di Pierro
Jonathan is right. Here is a simple way around.

Create a single controller called dynamical. use request.args(0) to
parse the name of one of the dynamical actions and remap

def dynamical():
 actionname, request.args[:] = request.args(0), request.args[1:]
 # call actionname and pass request.args and request.vars

use routes to remove the 'dynamical/' part form the URL.

This allows you to do what you want without necessarily meta-
programming.

On Jul 6, 9:35 am, Miguel Lopes  wrote:
> Thanks. In conjunction with routes could supply a solution (shortening the
> urls).
> I think I should rethink the payoff (see my reply to Massimo regarding my
> goals).
> Thanks,
> Miguel
>
>
>
>
>
>
>
> On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell  wrote:
> > On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
>
> > I'm experimenting with dynamically generating functions, aka 'actions' in
> > controllers. However, I've been unsuccessful. I can use exec and closures
> > successfully in regular Python code, but I can't make it work with web2py.
> > Any thoughts on how to achieve this?
>
> > web2py finds functions by reading the (static) controller file itself. See
> > gluon.compileapp.run_controller_in, in particular this line:
>
> >         exposed = regex_expose.findall(code)
>
> > So, no dynamically generated controller actions, at least not directly.
>
> > I haven't given this much thought, but one way you might accomplish the
> > same effect would be to push the dynamic function name down one level in the
> > URL, something like:http://domain.com/app/dynamic/index/function/...
>
> > ...where 'dynamic' is the controller with dynamic functions, and index is a
> > (static) function that calls function dynamically. You might optimize the
> > lookup function to extract only the one desired function from your page
> > table.
>
> > Depending on your overall URL structure, you could rewrite the URLs to
> > shorten them up.
>
> > A closure example - FAILS in web2py:
> > top_pages = db(db.page.id > 0).select()
> > def add_actions(top_pages):
> >     for page in top_pages:
> >         def inneraction(msg):
> >             sidebar = None
> >             return dict(message=msg, sidebar=sidebar)
> >         inneraction.__name__ = page.link_name
> >         globals()[page.link_name] = inneraction
>
> > add_actions(top_pages)
>
> > A exec example - FAILS in web2py:
>
> > ACTION_TEMPLATE = """
> >  def NEW_ACTION():
> >     sidebar = None
> >     return dict(message='s', sidebar=sidebar)
> >  """
> > top_pages = db(db.page.id > 0).select()
> > def makePages(pages):
> >     for page in top_pages:
> >         exec ACTION_TEMPLATE
> >         NEW_ACTION.__name__ = page.link_name
> >         globals()[page.link_name] = NEW_ACTION
>
> > makePages(pages)
>
> > Miguel


[web2py] Re: bug with default view

2011-07-06 Thread Anthony
1.96.1 -- see http://www.web2py.com/examples/default/changelog

On Wednesday, July 6, 2011 10:33:12 AM UTC-4, Oskari wrote:

> When has this behaviour changed? I can't seem to find it on log 
>
> On Jun 17, 7:33 pm, Jose  wrote: 
> > On 17 jun, 11:35, Anthony  wrote: 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > > On Friday, June 17, 2011 10:16:16 AM UTC-4, Jose wrote: 
> > 
> > > > Hi, 
> > 
> > > > In later versions of the trunk the default view does not work. If I 
> > > > create a function without creating ls associated view, should load 
> the 
> > > > default view, well, this is what fails. [invalid view] 
> > 
> > > Are you having this problem with requests on the local machine, or only 
>
> > > remote requests? Due to a security vulnerability, generic views are 
> turned 
> > > off by default unless the request is local. In db.py of the 'welcome' 
> app, 
> > > the following has been added: 
> > 
> > >response.generic_patterns= ['*'] if request.is_local else [] 
> > 
> > >response.generic_patternsis a list of glob patterns that can be used to 
> > > match /controller/function.extension to determine which generic views 
> should 
> > > be available for which controllers and functions. The above line allows 
> all 
> > > generic views, but only when request.is_local is True. You can set the 
> > > generic_patterns centrally in a model file (as above), or you can set 
> it 
> > > within specific controllers or functions. For example: 
> > 
> > > In default.py: 
> > 
> > > def myaction(): 
> > >response.generic_patterns= ['html', 'load'] 
> > > # more code 
> > > return dict(...) 
> > 
> > > The above will enable generic.html and generic.load views specifically 
> for 
> > > requests to /default/myaction.[html/load]. 
> > 
> > > Anthony 
> > 
> > Thanks Anthony.



Re: [web2py] Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
Thanks. In conjunction with routes could supply a solution (shortening the
urls).
I think I should rethink the payoff (see my reply to Massimo regarding my
goals).
Thanks,
Miguel

On Wed, Jul 6, 2011 at 3:12 PM, Jonathan Lundell  wrote:

> On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
>
> I'm experimenting with dynamically generating functions, aka 'actions' in
> controllers. However, I've been unsuccessful. I can use exec and closures
> successfully in regular Python code, but I can't make it work with web2py.
> Any thoughts on how to achieve this?
>
>
> web2py finds functions by reading the (static) controller file itself. See
> gluon.compileapp.run_controller_in, in particular this line:
>
> exposed = regex_expose.findall(code)
>
> So, no dynamically generated controller actions, at least not directly.
>
> I haven't given this much thought, but one way you might accomplish the
> same effect would be to push the dynamic function name down one level in the
> URL, something like: http://domain.com/app/dynamic/index/function/...
>
> ...where 'dynamic' is the controller with dynamic functions, and index is a
> (static) function that calls function dynamically. You might optimize the
> lookup function to extract only the one desired function from your page
> table.
>
> Depending on your overall URL structure, you could rewrite the URLs to
> shorten them up.
>
>
> A closure example - FAILS in web2py:
> top_pages = db(db.page.id > 0).select()
> def add_actions(top_pages):
> for page in top_pages:
> def inneraction(msg):
> sidebar = None
> return dict(message=msg, sidebar=sidebar)
> inneraction.__name__ = page.link_name
> globals()[page.link_name] = inneraction
>
> add_actions(top_pages)
>
> A exec example - FAILS in web2py:
>
> ACTION_TEMPLATE = """
>  def NEW_ACTION():
> sidebar = None
> return dict(message='s', sidebar=sidebar)
>  """
> top_pages = db(db.page.id > 0).select()
> def makePages(pages):
> for page in top_pages:
> exec ACTION_TEMPLATE
> NEW_ACTION.__name__ = page.link_name
> globals()[page.link_name] = NEW_ACTION
>
> makePages(pages)
>
> Miguel
>
>
>
>


[web2py] Re: bug with default view

2011-07-06 Thread Oskari
When has this behaviour changed? I can't seem to find it on log

On Jun 17, 7:33 pm, Jose  wrote:
> On 17 jun, 11:35, Anthony  wrote:
>
>
>
>
>
>
>
>
>
> > On Friday, June 17, 2011 10:16:16 AM UTC-4, Jose wrote:
>
> > > Hi,
>
> > > In later versions of the trunk the default view does not work. If I
> > > create a function without creating ls associated view, should load the
> > > default view, well, this is what fails. [invalid view]
>
> > Are you having this problem with requests on the local machine, or only
> > remote requests? Due to a security vulnerability, generic views are turned
> > off by default unless the request is local. In db.py of the 'welcome' app,
> > the following has been added:
>
> >response.generic_patterns= ['*'] if request.is_local else []
>
> >response.generic_patternsis a list of glob patterns that can be used to
> > match /controller/function.extension to determine which generic views should
> > be available for which controllers and functions. The above line allows all
> > generic views, but only when request.is_local is True. You can set the
> > generic_patterns centrally in a model file (as above), or you can set it
> > within specific controllers or functions. For example:
>
> > In default.py:
>
> > def myaction():
> >    response.generic_patterns= ['html', 'load']
> >     # more code
> >     return dict(...)
>
> > The above will enable generic.html and generic.load views specifically for
> > requests to /default/myaction.[html/load].
>
> > Anthony
>
> Thanks Anthony.


Re: [web2py] Re: Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
I putting together an interface where users can add pages to a site and have
these pages indistinguishable from "hard-coded" pages/functions. However, I
would have the best of both worlds and have very clean urls. Thus, I'm
trying to avoid things like:

/application/controller/catchall_function/page/1/12
/application/controller/catchall_function?_page=books?title=12

And have something like:

/application/controller/books/12

I know I could use routes to send everything to a function to process the
response, but I was wondering about doing this with closures.

Thanks,
Miguel


On Wed, Jul 6, 2011 at 1:57 PM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Can you explain the goal?
>
> On Jul 6, 3:23 am, Miguel Lopes  wrote:
> > I'm experimenting with dynamically generating functions, aka 'actions' in
> > controllers. However, I've been unsuccessful. I can use exec and closures
> > successfully in regular Python code, but I can't make it work with
> web2py.
> > Any thoughts on how to achieve this?
> >
> > A closure example - FAILS in web2py:
> >
> > top_pages = db(db.page.id > 0).select()
> >
> > def add_actions(top_pages):
> >
> > for page in top_pages:
> >
> > def inneraction(msg):
> >
> > sidebar = None
> >
> > return dict(message=msg, sidebar=sidebar)
> >
> > inneraction.__name__ = page.link_name
> >
> > globals()[page.link_name] = inneraction
> >
> > add_actions(top_pages)
> >
> > A exec example - FAILS in web2py:
> >
> > ACTION_TEMPLATE = """
> >
> >  def NEW_ACTION():
> >
> > sidebar = None
> >
> > return dict(message='s', sidebar=sidebar)
> >
> >  """
> >
> > top_pages = db(db.page.id > 0).select()
> >
> > def makePages(pages):
> >
> > for page in top_pages:
> >
> > exec ACTION_TEMPLATE
> >
> > NEW_ACTION.__name__ = page.link_name
> >
> > globals()[page.link_name] = NEW_ACTION
> >
> > makePages(pages)
> >
> > Miguel
>


Re: [web2py] Re: cron "Too many open files" regression?

2011-07-06 Thread John Duddy
It was my understanding that Python's GC frees any resources not explicitly
freed, and cron runs jobs in a try/except/finally block and rolls back any
uncommitted transactions.

I have reproduced the issue with the three running sequentially, and in
every case, the logs indicate that my functions exit, meaning that the
rollback (I'm committing) and GC actions should occur, or at the very least,
the OS should close/release stuff when the crom process exits.

Hmmm.. This is going to be interesting to track down.

On Wed, Jul 6, 2011 at 5:56 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Yes that is the problem wit cron issue. If one of the processes locks
> a resource, cron does not know about it and keeps spawning processes
> as scheduled. The new processes find the resource locked and freeze of
> crash but use ram. This is not a bug because cron is not supposed to
> know what the tasks do. This is a general logic problem with cron.
> Using one single background process that loops and sleeps is much
> safer.
>
> Massimo
>
> On Jul 6, 1:34 am, ron_m  wrote:
> > Sounds like some kind of race condition between the cron scripts because
> it
> > doesn't happen every time. Is there any chance the 3 cron scripts are
> > dependent on each other in some way such as a file passed between or
> sharing
> > a database. If there is any relationship between the cron scripts would
> it
> > be possible to make a single script that just runs the 3 scripts
> > sequentially and use that as your cron script. Do the scripts access the
> > database and the database happens to be SQLite which locks for the
> duration
> > of an access/
> >
> > Without seeing some code and more details determining the cause is a
> guess.
> >
> > Ron
>



-- 
John Duddy
jdu...@gmail.com


Re: [web2py] Metaprogramming in controller

2011-07-06 Thread Jonathan Lundell
On Jul 6, 2011, at 1:23 AM, Miguel Lopes wrote:
> I'm experimenting with dynamically generating functions, aka 'actions' in 
> controllers. However, I've been unsuccessful. I can use exec and closures 
> successfully in regular Python code, but I can't make it work with web2py. 
> Any thoughts on how to achieve this?

web2py finds functions by reading the (static) controller file itself. See 
gluon.compileapp.run_controller_in, in particular this line:

exposed = regex_expose.findall(code)

So, no dynamically generated controller actions, at least not directly.

I haven't given this much thought, but one way you might accomplish the same 
effect would be to push the dynamic function name down one level in the URL, 
something like: http://domain.com/app/dynamic/index/function/...

...where 'dynamic' is the controller with dynamic functions, and index is a 
(static) function that calls function dynamically. You might optimize the 
lookup function to extract only the one desired function from your page table.

Depending on your overall URL structure, you could rewrite the URLs to shorten 
them up.

> 
> A closure example - FAILS in web2py:
> top_pages = db(db.page.id > 0).select()
> def add_actions(top_pages):
> for page in top_pages:
> def inneraction(msg):
> sidebar = None
> return dict(message=msg, sidebar=sidebar)
> inneraction.__name__ = page.link_name
> globals()[page.link_name] = inneraction
> 
> add_actions(top_pages)
> 
> A exec example - FAILS in web2py:
> ACTION_TEMPLATE = """
>  def NEW_ACTION():
> sidebar = None
> return dict(message='s', sidebar=sidebar)
>  """
> top_pages = db(db.page.id > 0).select()
> def makePages(pages):
> for page in top_pages:
> exec ACTION_TEMPLATE
> NEW_ACTION.__name__ = page.link_name
> globals()[page.link_name] = NEW_ACTION
> 
> makePages(pages)
> 
> Miguel
> 




[web2py] Re: Error on LOAD() in trunk

2011-07-06 Thread Anthony
On Wednesday, July 6, 2011 1:20:30 AM UTC-4, GoldenTiger wrote: 
>
> I referred to generic views by default, like 
> http://web2py.com/examples/simple_examples/hello6 
> and discussed recently here 
>
> Invalid view in 1.97.1: 
>
> https://groups.google.com/group/web2py/browse_thread/thread/c3a14f5ee0997e2a/3b6898c0e70e8dd2
>  
>
> I agree the security issue, in fact I have thought so since ever, but 
> in my opinion, It has not been taken on mind some cases affected by 
> this change

 
Do you have a suggested alternative? I think this is a case where we cannot 
both maintain backward compatibility _and_ fix the security 
vulnerability. Note, if any of your apps were broken by this security fix, 
you can restore those apps to their original behavior by adding just a 
single line to any model file:
 
response.generic_patterns = ['*']
 
 
However, it would probably be wise to instead be more selective with which 
generic views are available for which requested controllers/functions (which 
is the intention behind the new response.generic_patterns functionality).
 
Anthony
 


[web2py] Re: Metaprogramming in controller

2011-07-06 Thread Massimo Di Pierro
Can you explain the goal?

On Jul 6, 3:23 am, Miguel Lopes  wrote:
> I'm experimenting with dynamically generating functions, aka 'actions' in
> controllers. However, I've been unsuccessful. I can use exec and closures
> successfully in regular Python code, but I can't make it work with web2py.
> Any thoughts on how to achieve this?
>
> A closure example - FAILS in web2py:
>
> top_pages = db(db.page.id > 0).select()
>
> def add_actions(top_pages):
>
>     for page in top_pages:
>
>         def inneraction(msg):
>
>             sidebar = None
>
>             return dict(message=msg, sidebar=sidebar)
>
>         inneraction.__name__ = page.link_name
>
>         globals()[page.link_name] = inneraction
>
> add_actions(top_pages)
>
> A exec example - FAILS in web2py:
>
> ACTION_TEMPLATE = """
>
>  def NEW_ACTION():
>
>     sidebar = None
>
>     return dict(message='s', sidebar=sidebar)
>
>  """
>
> top_pages = db(db.page.id > 0).select()
>
> def makePages(pages):
>
>     for page in top_pages:
>
>         exec ACTION_TEMPLATE
>
>         NEW_ACTION.__name__ = page.link_name
>
>         globals()[page.link_name] = NEW_ACTION
>
> makePages(pages)
>
> Miguel


[web2py] Re: cron "Too many open files" regression?

2011-07-06 Thread Massimo Di Pierro
Yes that is the problem wit cron issue. If one of the processes locks
a resource, cron does not know about it and keeps spawning processes
as scheduled. The new processes find the resource locked and freeze of
crash but use ram. This is not a bug because cron is not supposed to
know what the tasks do. This is a general logic problem with cron.
Using one single background process that loops and sleeps is much
safer.

Massimo

On Jul 6, 1:34 am, ron_m  wrote:
> Sounds like some kind of race condition between the cron scripts because it
> doesn't happen every time. Is there any chance the 3 cron scripts are
> dependent on each other in some way such as a file passed between or sharing
> a database. If there is any relationship between the cron scripts would it
> be possible to make a single script that just runs the 3 scripts
> sequentially and use that as your cron script. Do the scripts access the
> database and the database happens to be SQLite which locks for the duration
> of an access/
>
> Without seeing some code and more details determining the cause is a guess.
>
> Ron


[web2py] Re: Temporary changing default values of a Form

2011-07-06 Thread Massimo Di Pierro
You would suggest you do this instead

db.table.email.writable=False

in the controller, before defining the form.

Setting the field readonly in the view may still allow a malicious
attacker to tamper with the field value.

On Jul 6, 1:12 am, Luis Goncalves  wrote:
> I found the answer searching through the group posts:
>
>          form.element(_name='email')['_readonly']=True
>
> although this doesn't seem to be documented in the manual,
> and even looking through the gluon directory (and grepping for  _readonly )
> didn't reveal anything.
>
> Would this have been obvious to someone more proficient with web2py (I've
> only been using it for about a month)?
>
> thx!
>
> Luis.


[web2py] Re: Error on LOAD() in trunk

2011-07-06 Thread Massimo Di Pierro
This has been fixed in trunk. Anthony pointed it out to me one week
ago.

On Jul 6, 12:20 am, GoldenTiger  wrote:
> I referred to generic views by default, 
> likehttp://web2py.com/examples/simple_examples/hello6
> and discussed recently here
>
> Invalid view in 
> 1.97.1:https://groups.google.com/group/web2py/browse_thread/thread/c3a14f5ee...
>
> I agree the security issue, in fact I have thought so since ever, but
> in my opinion, It has not been taken on mind some cases affected by
> this change
>
> On 6 jul, 03:09, Anthony  wrote:
>
>
>
>
>
>
>
> > On Tuesday, July 5, 2011 8:38:07 PM UTC-4, GoldenTiger wrote:
>
> > > These last days, I have been reported by various customers about a lot
> > > of broken webapps.
> > >  I have to dedicate next days to review all these webs to patch  ,
> > > which I barely  remember how I did.
>
> > > So, this unexpected compatibility change, also it's an unexpected mail
> > > from an old customer.
>
> > What is the "compatibility change"? Is it the fact that the 'vars' argument
> > to LOAD is no longer ignored (and instead replaced with request.vars) when
> > ajax=False? Or is there something else that has changed?
>
> > Anthony


[web2py] Re: OffTopic Google+

2011-07-06 Thread Ross Peoples
I have tried it. I like it better than Facebook, especially because of its 
commitment to privacy. The circles feature is great. I think most people 
don't friend their bosses, coworkers, and business acquaintances of Facebook 
because they don't want their personal lives to be exposed to those people. 
However, with Google+, you can friend everyone you know and only share your 
personal weekend drunken parties with your Friends (and maybe Family) 
circle.

It's still missing a few key features (it is in beta after all), like the 
ability to write on someone's wall or send them a private message, but for 
the most part, it's pretty nice. I am really, REALLY pulling for Google 
here, as I hate Facebook.


[web2py] Re: web2py and DreamPie - The Python shell you've always dreamed about!

2011-07-06 Thread Vasil Petkov
I am interested in a work with that shell together with web2py, too.

As much as i know, web2py works with the IPython shell.

On Jul 5, 12:38 pm, Bruno Rocha  wrote:
> Does anybody knows how can we run web2py in shell mode under DreamPie?
>
> http://dreampie.sourceforge.net/
>
> --
> Bruno Rocha
> [ About me:http://zerp.ly/rochacbruno]


Re: [web2py] easy way to validate a list of emails?

2011-07-06 Thread Bruno Rocha
https://gist.github.com/1066850


Re: [web2py] easy way to validate a list of emails?

2011-07-06 Thread Bruno Rocha
forget the latest, I wrote directly here in email and there were errors.

This is the tested code:

### put in models ###

class IS_EMAIL_LIST(object):
def __init__(self, error_message="Email %s is invalid", sep=","):
self.error_message = error_message
self.sep = sep

def __call__(self, value):
emails =
value.strip().replace('\n','').replace('\t','').split(self.sep)
for email in emails:
email = email.strip()
if IS_EMAIL()(email)[1] != None:
return (email, self.error_message % email)
return (emails, None)

db.define_table('emails',
Field('list','text', requires=IS_EMAIL_LIST())
)

###


Re: [web2py] easy way to validate a list of emails?

2011-07-06 Thread Bruno Rocha
Hi, you can create a custom validator for doing that

include this in any model:

### THE CUSTOM VALIDATOR ###
class IS_EMAIL_LIST(object):
def __init__(self, error_message='Email %s is invalid', sep=","):
self.format = format
self.error_message = error_message
self.sep = sep

def __call__(self, value):
emails = value.split(self.sep)
for email in emails:
if IS_EMAIL()(email)[1] != None:
return (email, error_message % email)
return (emails, None)

### THE TABLE ###

db.define_table('emails',
Field('list','text', requires=IS_EMAIL_LIST())
)

#

NOTE: IS_EMAIL_LIST(sep=";") to change list separator


[]'s

On Wed, Jul 6, 2011 at 3:51 AM, Luis Goncalves  wrote:

> Hello!!!
>
> I have a form where an organizer can input a list of comma-separated email
> address, so that each person receives an invitation to register on the
> website (you can only register for the site if you have an invitation).
>
> Is there an easy way to get the  "if form.accepts()"   to use
> "requires=IS_EMAIL()"
> when the form element is not just a single email address, but a list of
> comma-separated email addresses?
>
> Thanks!
> Luis.
>



-- 



--
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] Metaprogramming in controller

2011-07-06 Thread Miguel Lopes
I'm experimenting with dynamically generating functions, aka 'actions' in
controllers. However, I've been unsuccessful. I can use exec and closures
successfully in regular Python code, but I can't make it work with web2py.
Any thoughts on how to achieve this?

A closure example - FAILS in web2py:

top_pages = db(db.page.id > 0).select()

def add_actions(top_pages):

for page in top_pages:

def inneraction(msg):

sidebar = None

return dict(message=msg, sidebar=sidebar)

inneraction.__name__ = page.link_name

globals()[page.link_name] = inneraction


add_actions(top_pages)


A exec example - FAILS in web2py:

ACTION_TEMPLATE = """

 def NEW_ACTION():

sidebar = None

return dict(message='s', sidebar=sidebar)

 """

top_pages = db(db.page.id > 0).select()

def makePages(pages):

for page in top_pages:

exec ACTION_TEMPLATE

NEW_ACTION.__name__ = page.link_name

globals()[page.link_name] = NEW_ACTION


makePages(pages)


Miguel