[web2py] Re: format and represent on table

2013-03-27 Thread Alex Glaros
just curious Steve,

are you writing a court app for government?

Alex Glaros

On Tuesday, March 26, 2013 10:43:53 PM UTC-7, 黄祥 wrote:
>
> hi,
>
> i've already define format in table but it seems return the id instead of 
> the format i've define, when i define represent on the field of the other 
> field it can work. is it normal?
>
> *e.g. work*
> db.define_table('booking',
> Field('scheduled_start', 'datetime'),
> Field('due_date', 'datetime'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name, 
>  r.customer.last_name, 
> r.court.branch.address, 
>  r.court.court_no))
>
> db.define_table('check_in',
> Field('is_booking', 'boolean'),
> Field('booking', 'reference booking'*, represent=lambda id, r: '%s 
> %s-%s-%s' % (r.customer.first_name, r.customer.last_name, 
> r.court.branch.address, r.court.court_no)*),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name, 
> r.customer.last_name, 
>   r.court.branch.address, 
> r.court.court_no))
>
>
> *e.g. not work*
> db.define_table('booking',
> Field('scheduled_start', 'datetime'),
> Field('due_date', 'datetime'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name, 
>  r.customer.last_name, 
> r.court.branch.address, 
>  r.court.court_no))
>
> db.define_table('check_in',
> Field('is_booking', 'boolean'),
> Field('booking', 'reference booking'),
> Field('court', 'reference court'),
> Field('customer', 'reference customer'),
> Field('description', 'text'),
> format=lambda r: '%s %s-%s-%s' % (r.customer.first_name, 
> r.customer.last_name, 
>   r.court.branch.address, 
> r.court.court_no))
>
> thank you very much in advance
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] is there a stable blog app for web2py ?

2013-03-27 Thread RunSky ruan
I need a blog app for my website.
Is there a stable blog app for web2py,the instant-press seems last update 
at 2010,it's not updated for a long time

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: How to display 'text' field contents in several paragraphs rather than in single line

2013-03-27 Thread Spring
Thanks Anthony, it works perfectly.

在 2013年3月27日星期三UTC+8下午9时10分28秒,Anthony写道:
>
> When a text field is submitted, line breaks are stored as standard line 
> break characters (i.e., "\n"). When you then insert the stored text into 
> HTML, the line breaks will be included in the HTML, but browsers ignore 
> line breaks when rendering (i.e., they are treated as single spaces). If 
> you want to convert text line breaks to HTML line breaks (i.e.,  
> elements), you have to do so explicitly -- for example:
>
> {{=XML(lead.f_description.replace('\n', ''), sanitize=True)}}
>
> Wrapping the string in XML() is necessary to prevent the web2py template 
> engine from escaping the  elements, and sanitize=True keeps XML() 
> safe from insecure code that might be injected into the submitted text.
>
> Anthony
>
> On Wednesday, March 27, 2013 3:33:50 AM UTC-4, Spring wrote:
>>
>> Hello there,
>>
>> I have defined a 'text' field in the table. The content consists of 
>> multiple paragraphs, when displayed in the view the content squeezes into a 
>> single line. It seems all 'enter' in original text was replaced by a 
>> "space". How can I display the text as paragraphs as it is input? Thanks 
>> for any replay.
>>
>> related piece of code:
>>
>> #Model
>> db.define_table('t_leads',
>> Field('f_owner', type='string',
>>   label=T('Owner')),
>> Field('f_location', type='string',
>>   label=T('Location')),
>> Field('f_status', type='string',
>>   label=T('Status')),
>> Field('f_description', type='text',
>>   label=T('Description')),
>> auth.signature,
>>
>> format='%(f_lead_designation)s',
>> migrate=settings.migrate)
>>
>>
>> #View
>> {{=lead.f_description}}
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] datetime diff between tables

2013-03-27 Thread 黄祥
hi,

is it possible to get datetime diff betwen tables?

e.g.
db.define_table('check_in',
Field('is_booking', 'boolean'),
Field('booking', 'reference booking'),
Field('room', 'reference room'),
Field('guest', 'reference guest'),
Field('description', 'text'),
format='%(description)s')

db.define_table('check_out',
Field('check_in', 'reference check_in'),
Field('room', 'reference room'),
Field('guest', 'reference guest'),
Field('description', 'text'),
Field('duration', *compute=lambda r: 
r['created_on']-r['check_in.created_on']*),
format='%(guest)s %(room)s')

when i test, it returns 0:00:00 in duration field.
any hints or suggestion to handle this?
thank you very much before

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: format and represent on table

2013-03-27 Thread 黄祥
a, i c, thank you so much for your detail explaination, massimo.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] view error tickets in admin when stored in db

2013-03-27 Thread Eric S

I'm storing my web2py error tickets in a database. However, the admin 
interface to the database doesn't show the tickets table. Is this correct? 
If so, why not show the tickets table?

Thanks,
Eric

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: LOAD() and auth.requires_login() - Nice "please login" message??

2013-03-27 Thread Anthony
Good point -- I'm not sure I agree that 401 should be forced for Ajax 
requests -- we should probably have an option to allow Ajax requests to be 
treated the same as other requests (maybe open an issue about it). (In 
fact, the old "elif request.ajax" condition was left in the code, even 
though it can never execute.) For now, though, you have several options:

   - If you want to customize the 401 message, see 
   http://web2py.com/books/default/chapter/29/04#Routes-on-error.
   - Check for the 401 on the client side via Javascript and take the 
   appropriate action there.
   - Instead of decorating the function, you can simply check for auth.user 
   within the function and take whatever action you prefer if the user isn't 
   logged in.
   - Do something like this:

 if request.ajax:
 auth.settings.on_failed_authorization = auth.settings.login_url
 ...  

 @auth.requires(auth.user, requires_login=False)

That uses the generic @auth.requires(), checking for the existence of 
auth.user, but not explicitly running the requires_login code. In this 
case, failure redirects to the auth.settings.on_failed_authorization URL, 
which is why that is reset to the login_url for Ajax requests.

Anthony

On Wednesday, March 27, 2013 7:16:41 PM UTC-4, Brian M wrote:
>
> I have a page that is using LOAD() to pull in a form that requires the 
> user to be logged-in (@auth.requires_login())  In previous versions of 
> web2py if the user hadn't yet logged in they'd get the login screen within 
> the LOAD()'s DIV and at least could get an idea of what they needed to do 
> before proceeding, but now with the current version they just see "401 NOT 
> AUTHORIZED" which just completely confuses my users.  It appears that this 
> change was made in response to issue 
> 832in
>  this 
> commit.
>  
>  Is there at least some way to specify my own message instead so it says 
> something like "Please log-in" rather than "401 NOT AUTHORIZED"?
>
> Thanks,
> ~Brian
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLForm.factory

2013-03-27 Thread Anthony
No problem. Glad it's working. :-)

On Wednesday, March 27, 2013 6:32:37 PM UTC-4, BlueShadow wrote:
>
> Anthony you saved my day.
> If you want to I include you in my humans.txt under special thanks.
> I couldn't have done it without you.
>
> On Wednesday, March 27, 2013 11:14:50 PM UTC+1, Anthony wrote:
>>
>> SQLFORM.factory creates a dummy DAL instance and a dummy table with the 
>> default name "no_table". To change that, do:
>>
>> SQLFORM.factory(..., table_name='Image')
>>
>> Anthony
>>
>> On Wednesday, March 27, 2013 6:08:23 PM UTC-4, BlueShadow wrote:
>>>
>>> thanks Anthony and Richard. I guess I didn't understand the SQLFORM.factory 
>>> and what it does. I get now my thumbnail and all dbentries as I like 
>>> except the main Image Itself. there is a value in the database and the 
>>> image is saved but I guess the Name already tells that there is something 
>>> screwy: 
>>> no_table.Image.9721d2f2a2f77f4d.537461727472656b5f73315f636f766572312e6a7067.jpg
>>> So I guess I have to tell web2py somehow what the right naming pattern 
>>> should be.
>>> Oh man when I started the plan to add this feature I thought thats easy 
>>> ^^ I'm really sorry for my lack off understanding. 
>>> Sry about the client in the previous code^^
>>> My corrected code now:
>>>
>>> def newImage():
>>> dbtable = db.Images  #uploads table name
>>> if len(request.args):
>>> records = db(dbtable.id==request.args[0]).select()
>>> print "len(request.args)",records
>>> if len(request.args) and len(records):
>>> form = SQLFORM(dbtable, records[0], deletable=True)
>>> else:
>>> form = SQLFORM.factory(dbtable,db.image_references)
>>> if form.process().accepted:
>>> response.flash = 'Entry for Images Database accepted,start 
>>> creating thumb'
>>> id = db.Images.insert(**db.Images._filter_fields(form.vars))
>>> form.vars.image_id=id
>>> id = db.image_references.insert(**db.image_references.
>>> _filter_fields(form.vars))
>>> thisImage=db(dbtable.id==form.vars.image_id).select()
>>> thisImage=thisImage[0]
>>> makeThumbnail(dbtable,form.vars.image_id,(200,200))
>>>
>>>
>>>
>>> here is my thumbnail funktion or should I say your funktion Anthony:)
>>> def makeThumbnail(dbtable,ImageID,size=(200,200)):
>>> """ This code is mostly from web2pyslices but the person who really 
>>> made it work was Anthony thanks for that """
>>> try:
>>> thisImage=db(dbtable.id==ImageID).select()[0]
>>> import os, uuid
>>> except: 
>>> print "Error while loading libraries"
>>> return
>>> try:
>>> from PIL import Image
>>> except:
>>> print "Error while Importing PIL library"
>>> return
>>> im=Image.open(request.folder + 'uploads/' + thisImage.Image)
>>> im.thumbnail(size,Image.ANTIALIAS)
>>> """ Thanks to Anthony for this code he is the best :) """
>>> from cStringIO import StringIO
>>> tmp = StringIO()
>>> im.save(tmp, 'jpeg')
>>> tmp.seek(0)
>>> """ the rest is of this function is taken from web2pyslices thank 
>>> you guys too you are a real help """
>>> thisImage.update_record(thumb=db.Images.thumb.store(tmp, filename=
>>> 'thumbnail.jpg'))
>>> response.flash = 'Database entry Added. Image stored and Thumbnail 
>>> created'
>>> return
>>>
>>>
>>>
>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] facebook connect

2013-03-27 Thread Michele Comitini
Use oauth2.0 integrated module:
http://web2py.com/books/default/chapter/29/09?search=oauth#Other-login-methods-and-login-forms.

mic


2013/3/26 ctrlSoft :
> hi, i want to implement 2 kind of login on my app.
> 1) basic auth
> 2) facebook connect
> i extended auth_user
>
> auth.settings.extra_fields['auth_user']= [
>   Field('ballance', type='double', default=0, writable=False,
> readable=False),
>   Field('image', type='string'),
>   Field('phone', type='integer'),
>   Field('birthday', type='date')]
>
>
> auth.define_tables(username=True, signature=False)
>
> i want when user connect with facebook to insert in auth_user new record
> with facebook data (firstname, lastname, birthday, profile picture .)
> do you have a working example?
> what is the best practice?
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] LOAD() and auth.requires_login() - Nice "please login" message??

2013-03-27 Thread Brian M
I have a page that is using LOAD() to pull in a form that requires the user 
to be logged-in (@auth.requires_login())  In previous versions of web2py if 
the user hadn't yet logged in they'd get the login screen within the 
LOAD()'s DIV and at least could get an idea of what they needed to do 
before proceeding, but now with the current version they just see "401 NOT 
AUTHORIZED" which just completely confuses my users.  It appears that this 
change was made in response to issue 
832in
 this 
commit.
 
 Is there at least some way to specify my own message instead so it says 
something like "Please log-in" rather than "401 NOT AUTHORIZED"?

Thanks,
~Brian

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLForm.factory

2013-03-27 Thread BlueShadow
Anthony you saved my day.
If you want to I include you in my humans.txt under special thanks.
I couldn't have done it without you.

On Wednesday, March 27, 2013 11:14:50 PM UTC+1, Anthony wrote:
>
> SQLFORM.factory creates a dummy DAL instance and a dummy table with the 
> default name "no_table". To change that, do:
>
> SQLFORM.factory(..., table_name='Image')
>
> Anthony
>
> On Wednesday, March 27, 2013 6:08:23 PM UTC-4, BlueShadow wrote:
>>
>> thanks Anthony and Richard. I guess I didn't understand the SQLFORM.factory 
>> and what it does. I get now my thumbnail and all dbentries as I like 
>> except the main Image Itself. there is a value in the database and the 
>> image is saved but I guess the Name already tells that there is something 
>> screwy: 
>> no_table.Image.9721d2f2a2f77f4d.537461727472656b5f73315f636f766572312e6a7067.jpg
>> So I guess I have to tell web2py somehow what the right naming pattern 
>> should be.
>> Oh man when I started the plan to add this feature I thought thats easy 
>> ^^ I'm really sorry for my lack off understanding. 
>> Sry about the client in the previous code^^
>> My corrected code now:
>>
>> def newImage():
>> dbtable = db.Images  #uploads table name
>> if len(request.args):
>> records = db(dbtable.id==request.args[0]).select()
>> print "len(request.args)",records
>> if len(request.args) and len(records):
>> form = SQLFORM(dbtable, records[0], deletable=True)
>> else:
>> form = SQLFORM.factory(dbtable,db.image_references)
>> if form.process().accepted:
>> response.flash = 'Entry for Images Database accepted,start 
>> creating thumb'
>> id = db.Images.insert(**db.Images._filter_fields(form.vars))
>> form.vars.image_id=id
>> id = db.image_references.insert(**db.image_references.
>> _filter_fields(form.vars))
>> thisImage=db(dbtable.id==form.vars.image_id).select()
>> thisImage=thisImage[0]
>> makeThumbnail(dbtable,form.vars.image_id,(200,200))
>>
>>
>>
>> here is my thumbnail funktion or should I say your funktion Anthony:)
>> def makeThumbnail(dbtable,ImageID,size=(200,200)):
>> """ This code is mostly from web2pyslices but the person who really 
>> made it work was Anthony thanks for that """
>> try:
>> thisImage=db(dbtable.id==ImageID).select()[0]
>> import os, uuid
>> except: 
>> print "Error while loading libraries"
>> return
>> try:
>> from PIL import Image
>> except:
>> print "Error while Importing PIL library"
>> return
>> im=Image.open(request.folder + 'uploads/' + thisImage.Image)
>> im.thumbnail(size,Image.ANTIALIAS)
>> """ Thanks to Anthony for this code he is the best :) """
>> from cStringIO import StringIO
>> tmp = StringIO()
>> im.save(tmp, 'jpeg')
>> tmp.seek(0)
>> """ the rest is of this function is taken from web2pyslices thank 
>> you guys too you are a real help """
>> thisImage.update_record(thumb=db.Images.thumb.store(tmp, filename=
>> 'thumbnail.jpg'))
>> response.flash = 'Database entry Added. Image stored and Thumbnail 
>> created'
>> return
>>
>>
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Error when listing newly created database tables from appadmin

2013-03-27 Thread Derek
Right, if you use the 'reference sometable' syntax, that will allow you to 
have tables reference something which doesn't exist yet. If you use the 
db.othertable format, then the othertable absolutely has to exist.

On Monday, March 25, 2013 7:48:02 AM UTC-7, Cliff Kachinske wrote:
>
> As I understand it, the table does not have to exist when using the 
> 'reference sometable' syntax.  Or anyway that's how it's supposed to work.
>
> I'm not 100% confident in it, though so I always make it a practice to 
> create the reference tables first.
>
> On Monday, March 25, 2013 6:31:16 AM UTC-4, Alan Etkin wrote:
>>
>> I think I kinda figured out the problem. The order of defining tables 
>>> seems matter. Tables to be referenced need to be defined before the 
>>> referencing tables. Guess it's a rookie mistake.
>>
>>  
>> I don't think it's a matter of table definition order. Maybe there aren't 
>> any referenced records in the table so the dropdown widget is not created.
>>
>> About the modified_on created_on, web2py has some features that create 
>> tables under the hood, i.e., for record versioning. Perhaps you want to 
>> disable them at the model by changing the feature options (they are 
>> documented in the book)
>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLForm.factory

2013-03-27 Thread Anthony
SQLFORM.factory creates a dummy DAL instance and a dummy table with the 
default name "no_table". To change that, do:

SQLFORM.factory(..., table_name='Image')

Anthony

On Wednesday, March 27, 2013 6:08:23 PM UTC-4, BlueShadow wrote:
>
> thanks Anthony and Richard. I guess I didn't understand the SQLFORM.factory 
> and what it does. I get now my thumbnail and all dbentries as I like 
> except the main Image Itself. there is a value in the database and the 
> image is saved but I guess the Name already tells that there is something 
> screwy: 
> no_table.Image.9721d2f2a2f77f4d.537461727472656b5f73315f636f766572312e6a7067.jpg
> So I guess I have to tell web2py somehow what the right naming pattern 
> should be.
> Oh man when I started the plan to add this feature I thought thats easy ^^ 
> I'm really sorry for my lack off understanding. 
> Sry about the client in the previous code^^
> My corrected code now:
>
> def newImage():
> dbtable = db.Images  #uploads table name
> if len(request.args):
> records = db(dbtable.id==request.args[0]).select()
> print "len(request.args)",records
> if len(request.args) and len(records):
> form = SQLFORM(dbtable, records[0], deletable=True)
> else:
> form = SQLFORM.factory(dbtable,db.image_references)
> if form.process().accepted:
> response.flash = 'Entry for Images Database accepted,start 
> creating thumb'
> id = db.Images.insert(**db.Images._filter_fields(form.vars))
> form.vars.image_id=id
> id = db.image_references.insert(**db.image_references.
> _filter_fields(form.vars))
> thisImage=db(dbtable.id==form.vars.image_id).select()
> thisImage=thisImage[0]
> makeThumbnail(dbtable,form.vars.image_id,(200,200))
>
>
>
> here is my thumbnail funktion or should I say your funktion Anthony:)
> def makeThumbnail(dbtable,ImageID,size=(200,200)):
> """ This code is mostly from web2pyslices but the person who really 
> made it work was Anthony thanks for that """
> try:
> thisImage=db(dbtable.id==ImageID).select()[0]
> import os, uuid
> except: 
> print "Error while loading libraries"
> return
> try:
> from PIL import Image
> except:
> print "Error while Importing PIL library"
> return
> im=Image.open(request.folder + 'uploads/' + thisImage.Image)
> im.thumbnail(size,Image.ANTIALIAS)
> """ Thanks to Anthony for this code he is the best :) """
> from cStringIO import StringIO
> tmp = StringIO()
> im.save(tmp, 'jpeg')
> tmp.seek(0)
> """ the rest is of this function is taken from web2pyslices thank you 
> guys too you are a real help """
> thisImage.update_record(thumb=db.Images.thumb.store(tmp, filename=
> 'thumbnail.jpg'))
> response.flash = 'Database entry Added. Image stored and Thumbnail 
> created'
> return
>
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Why compute does not work to get image filename?

2013-03-27 Thread Tito Garrido
It would work, but if I delete a record and then add a new one it would get
the wrong id :-/


On Wed, Mar 27, 2013 at 6:40 PM, Niphlod  wrote:

> when dealing with first() or last(), remember that those come AFTER the
> select() ... when you do select().first() you're really fetching all from
> the db and discarding all but one row.
>
> The time difference may be negligible with a few records, but if you have
> lots of them, stick with limitby=(0,1) and orderby=field or orderby=~field
>
>
> On Wednesday, March 27, 2013 10:34:25 PM UTC+1, Roberto Perdomo wrote:
>
>> Sorry, the function must be return a string in order to concatenate with
>> the  filename
>> El mar 27, 2013 4:59 PM, "Roberto Perdomo"  escribió:
>>
>>>  And what about something like this:
>>>
>>> Field('image_filename', readable=False, writable=False, compute = lambda
>>> row: request.post_vars.image.**filename + next_id())
>>>
>>> def next_id():
>>> last_row = db().select(db.table.id).last(**)
>>> last_id = int(last_row[`table.id`])
>>> return last_id + 1
>>>
>>> This was written from my cel phone and dont test it but  hope that helps
>>> ;-)
>>>  El mar 27, 2013 3:25 PM, "Roberto Perdomo" 
>>> escribió:
>>>
  :-S
 I was thinking on represent attribute from fields, not compute.
 El mar 27, 2013 3:07 PM, "Niphlod"  escribió:

 boys . how can the id be present if what you're trying to insert is
> not yet a row in a table 
>
> On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:
>>
>> Ummm, the id is readable?
>>
>> db.table.id.readable = True
>> El mar 27, 2013 12:55 PM, "Tito Garrido" 
>> escribió:
>>
>>> I just checked... id is not present:
>>> ">> b2754a53c6cd**cc7e.**69626d2d4c6f676f2e6a7067.**jpg', 'novela':
>>> '9', 'slug': '', 'descricao': ''}>"
>>>
>>>
>>> On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo >> > wrote:
>>>
 Try:

 Field('image_filename', readable=False, writable=False, compute =
 lambda row: request.post_vars.image.**filena**me + row.id),
 El mar 27, 2013 12:39 PM, "Tito Garrido" 
 escribió:

 How could I also append the id of the row in image_filename?
>
> Thanks!
>
> Tito
>
>
> On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido 
> wrote:
>
>> Worked! It should go to the book :) http://web2py.com/books/**
>> defaul**t/chapter/29/07#Storing-**the-**original-filename
>>
>> Thanks!
>>
>> Tito
>>
>>
>> On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
>> massimo@gmail.com> wrote:
>>
>>> You can use this:
>>>  Field('image_filename', readable=False, writable=False, compute
>>> = lambda row: request.post_vars.image.**filena**me),
>>>
>>>
>>> On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:

 Hi!

 Why this does not work:
 Field('image', 'upload', requires=IS_NOT_EMPTY(),
 uploadseparate=True, autodelete=True,),
 Field('image_filename', readable=False, writable=False,
 compute = lambda row: row.image.filename),

 Using a form I can follow the book and fill the image filename:
 if request.vars.image!=None:
 try:
 form.vars.image_filename =
 request.vars.image.filename
 except:
 form.vars.image_filename = request.vars.image

 How can I do the same using SQLFORM.grid?

 Regards,

 Tito

 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___

>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the
>>> Google Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from
>>> it, send an email to web2py+un...@**googlegroups.com.
>>> For more options, visit https://groups.google.com/**grou**
>>> ps/opt_out .
>>>
>>>
>>>
>>
>>
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>
>
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.

Re: [web2py] using the IS_URL validator with complex URLs

2013-03-27 Thread Derek
Also looks like the TLDs don't include the internationalized country code 
top level domains, only the test ones.

On Wednesday, March 27, 2013 2:57:00 PM UTC-7, Derek wrote:
>
> It should be checking against RFC 3986, not RFC 2396.
>
> On Wednesday, March 27, 2013 11:44:08 AM UTC-7, Jonathan Lundell wrote:
>>
>> On 27 Mar 2013, at 11:25 AM, Lamps902  wrote:
>>
>> It seems that every once in a while, the IS_URL validator doesn't want to 
>> accept a URL that's valid. For example, I believe the ^ character prevents 
>> IS_URL from accepting something like 
>> http://finance.yahoo.com/q/hp?s=^IXIC+Historical+Prices.
>>  
>> Is there a parameter to permit IS_URL to accept certain special characters, 
>> or that makes the validator 'less strict', so that it can accept URLs such 
>> as the one above? Thanks.
>>
>>
>>
>> IS_URL first checks the URL against RFC 2396, which requires '^' to be 
>> escaped. I don't see a way to override it; better to URL-escape your URLs.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Anthony
Specifically, maybe something like this:

db.define_table('image',
Field('file', 'upload', represent=lambda v, r: A(generate_image(v),
  _href=URL('default', 'download', args=v, vars=dict(action=
'update_download_number', id=r.id,
Field('downloads', 'integer', default=0, writable=False))

def download():
if request.vars.action == 'update_download_number':
db.image(request.vars.id).update_record(downloads=db.image.downloads 
+ 1)
return response.download(request, db)

Anthony

On Wednesday, March 27, 2013 5:46:28 PM UTC-4, Anthony wrote:
>
> What do you mean by absolute vs. relative URLs in this case, and why does 
> that matter (i.e., show examples)? The URL function can generate absolute 
> URLs  by 
> specifying the scheme and host arguments, but it's not clear why you would 
> need that in this case. Note, if your URL includes args or vars used to 
> identify a specific record, then you can access the record identifier via 
> request.args or request.vars within the function called by the URL.
>
> Anthony
>
> On Wednesday, March 27, 2013 4:59:02 PM UTC-4, Lamps902 wrote:
>>
>> In the case that I'm dealing with, the image is incidental to the 
>> problem. But let's say there is an image, and a relative URL (i.e. file 
>> download); you can do something like this:
>>
>> db.my_db.file.represent = lambda x,y: \
>> A(generate_image(y.file),
>> _href=URL(args=["my_db/download", x],vars = 
>> dict(action="update_download_number", id=y.id)))
>>
>> Can't do this for absolute links. Maybe I'm misunderstanding your 
>> suggestion, but the same image generator function will be invoked for all 
>> of the rows in the table, so if I use that, all the rows end up being 
>> updated, as opposed to the one which should be updated. So basically, I 
>> think it comes down to how to go about creating a function that's invoked 
>> when an absolute link is clicked, and passing an identifier related 
>> specifically to that link to the function.
>>
>> On Wednesday, March 27, 2013 2:41:16 PM UTC-5, Niphlod wrote:
>>>
>>> so, you have an url (i.e. a string) that needs to return an image.
>>> you should have a controller that, when that URI is matched, returns the 
>>> image after increasing its number_visited value seems pretty standard 
>>> to me
>>>
>>> On Wednesday, March 27, 2013 7:15:12 PM UTC+1, Lamps902 wrote:

 Let's say you have an SQL grid generated from a db with field *my_url*, 
 which stores the value of an absolute URL, and has a representation 
 defined 
 in this way: 

 db.my_db.my_url.represent = lambda the_url, row: 
 A(generate_link_image(), _href=the_url, _target='_blank')

 What would be a good way to modify the above code so that when the link 
 is clicked, some field in *my_db* (for example, *number_visited*, 
 corresponding to the number of times the url has been clicked) is updated? 
 I'm not sure you can use _href=URL(...) with absolute links, and other 
 variants I've tried end up updating every record referenced in the table 
 rather than just the one that the user clicks. Thanks.

>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] SQLForm.factory

2013-03-27 Thread BlueShadow
thanks Anthony and Richard. I guess I didn't understand the SQLFORM.factory 
and what it does. I get now my thumbnail and all dbentries as I like except 
the main Image Itself. there is a value in the database and the image is 
saved but I guess the Name already tells that there is something screwy: 
no_table.Image.9721d2f2a2f77f4d.537461727472656b5f73315f636f766572312e6a7067.jpg
So I guess I have to tell web2py somehow what the right naming pattern 
should be.
Oh man when I started the plan to add this feature I thought thats easy ^^ 
I'm really sorry for my lack off understanding. 
Sry about the client in the previous code^^
My corrected code now:
def newImage():
dbtable = db.Images  #uploads table name
if len(request.args):
records = db(dbtable.id==request.args[0]).select()
print "len(request.args)",records
if len(request.args) and len(records):
form = SQLFORM(dbtable, records[0], deletable=True)
else:
form = SQLFORM.factory(dbtable,db.image_references)
if form.process().accepted:
response.flash = 'Entry for Images Database accepted,start creating 
thumb'
id = db.Images.insert(**db.Images._filter_fields(form.vars))
form.vars.image_id=id
id = 
db.image_references.insert(**db.image_references._filter_fields(form.vars))
thisImage=db(dbtable.id==form.vars.image_id).select()
thisImage=thisImage[0]
makeThumbnail(dbtable,form.vars.image_id,(200,200))

here is my thumbnail funktion or should I say your funktion Anthony:)
def makeThumbnail(dbtable,ImageID,size=(200,200)):
""" This code is mostly from web2pyslices but the person who really 
made it work was Anthony thanks for that """
try:
thisImage=db(dbtable.id==ImageID).select()[0]
import os, uuid
except: 
print "Error while loading libraries"
return
try:
from PIL import Image
except:
print "Error while Importing PIL library"
return
im=Image.open(request.folder + 'uploads/' + thisImage.Image)
im.thumbnail(size,Image.ANTIALIAS)
""" Thanks to Anthony for this code he is the best :) """
from cStringIO import StringIO
tmp = StringIO()
im.save(tmp, 'jpeg')
tmp.seek(0)
""" the rest is of this function is taken from web2pyslices thank you 
guys too you are a real help """
thisImage.update_record(thumb=db.Images.thumb.store(tmp, 
filename='thumbnail.jpg'))
response.flash = 'Database entry Added. Image stored and Thumbnail 
created'
return

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] using the IS_URL validator with complex URLs

2013-03-27 Thread Jonathan Lundell
On 27 Mar 2013, at 2:57 PM, Derek  wrote:
> It should be checking against RFC 3986, not RFC 2396.

Yes, it should be updated.

> 
> On Wednesday, March 27, 2013 11:44:08 AM UTC-7, Jonathan Lundell wrote:
> On 27 Mar 2013, at 11:25 AM, Lamps902  wrote:
>> It seems that every once in a while, the IS_URL validator doesn't want to 
>> accept a URL that's valid. For example, I believe the ^ character prevents 
>> IS_URL from accepting something like 
>> http://finance.yahoo.com/q/hp?s=^IXIC+Historical+Prices. Is there a 
>> parameter to permit IS_URL to accept certain special characters, or that 
>> makes the validator 'less strict', so that it can accept URLs such as the 
>> one above? Thanks.
>> 
>> 
> 
> IS_URL first checks the URL against RFC 2396, which requires '^' to be 
> escaped. I don't see a way to override it; better to URL-escape your URLs.
> 
> 


-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] using the IS_URL validator with complex URLs

2013-03-27 Thread Derek
It should be checking against RFC 3986, not RFC 2396.

On Wednesday, March 27, 2013 11:44:08 AM UTC-7, Jonathan Lundell wrote:
>
> On 27 Mar 2013, at 11:25 AM, Lamps902 > 
> wrote:
>
> It seems that every once in a while, the IS_URL validator doesn't want to 
> accept a URL that's valid. For example, I believe the ^ character prevents 
> IS_URL from accepting something like 
> http://finance.yahoo.com/q/hp?s=^IXIC+Historical+Prices.
>  
> Is there a parameter to permit IS_URL to accept certain special characters, 
> or that makes the validator 'less strict', so that it can accept URLs such 
> as the one above? Thanks.
>
>
>
> IS_URL first checks the URL against RFC 2396, which requires '^' to be 
> escaped. I don't see a way to override it; better to URL-escape your URLs.
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Anthony
What do you mean by absolute vs. relative URLs in this case, and why does 
that matter (i.e., show examples)? The URL function can generate absolute 
URLs  by 
specifying the scheme and host arguments, but it's not clear why you would 
need that in this case. Note, if your URL includes args or vars used to 
identify a specific record, then you can access the record identifier via 
request.args or request.vars within the function called by the URL.

Anthony

On Wednesday, March 27, 2013 4:59:02 PM UTC-4, Lamps902 wrote:
>
> In the case that I'm dealing with, the image is incidental to the problem. 
> But let's say there is an image, and a relative URL (i.e. file download); 
> you can do something like this:
>
> db.my_db.file.represent = lambda x,y: \
> A(generate_image(y.file),
> _href=URL(args=["my_db/download", x],vars = 
> dict(action="update_download_number", id=y.id)))
>
> Can't do this for absolute links. Maybe I'm misunderstanding your 
> suggestion, but the same image generator function will be invoked for all 
> of the rows in the table, so if I use that, all the rows end up being 
> updated, as opposed to the one which should be updated. So basically, I 
> think it comes down to how to go about creating a function that's invoked 
> when an absolute link is clicked, and passing an identifier related 
> specifically to that link to the function.
>
> On Wednesday, March 27, 2013 2:41:16 PM UTC-5, Niphlod wrote:
>>
>> so, you have an url (i.e. a string) that needs to return an image.
>> you should have a controller that, when that URI is matched, returns the 
>> image after increasing its number_visited value seems pretty standard 
>> to me
>>
>> On Wednesday, March 27, 2013 7:15:12 PM UTC+1, Lamps902 wrote:
>>>
>>> Let's say you have an SQL grid generated from a db with field *my_url*, 
>>> which stores the value of an absolute URL, and has a representation defined 
>>> in this way: 
>>>
>>> db.my_db.my_url.represent = lambda the_url, row: 
>>> A(generate_link_image(), _href=the_url, _target='_blank')
>>>
>>> What would be a good way to modify the above code so that when the link 
>>> is clicked, some field in *my_db* (for example, *number_visited*, 
>>> corresponding to the number of times the url has been clicked) is updated? 
>>> I'm not sure you can use _href=URL(...) with absolute links, and other 
>>> variants I've tried end up updating every record referenced in the table 
>>> rather than just the one that the user clicks. Thanks.
>>>
>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Lamps902
Thanks, Niphlod. It may require some digression/elaboration, so do you mind 
if I get in touch with you about this tomorrow? Hopefully, after I get some 
rest, I'll be able to articulate the issue a bit better...

On Wednesday, March 27, 2013 4:08:46 PM UTC-5, Niphlod wrote:
>
> uhm... I didn't quite understand, but it seems that you want different 
> things to happen when "printing" the url and when "accessing" the url.
> Why is hard separating "printing a link" logic from the "accessing the 
> link" one ?
> It's a common "construct", i.e. on one page 
>
> click here to "like" the image
>
> and on another page
>
> -
> image
> -
> you "liked this image"
>
> the second page, either accessed as a relative or as an absolute url, 
> makes no difference from the web2py standpoint.
>
> If I totally missed your requirements, can you give a "plain english" 
> explanation on what you're trying to accomplish ?
> PS: I'm on gtalk for the next hour if this requires a long digression :P
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Why compute does not work to get image filename?

2013-03-27 Thread Niphlod
when dealing with first() or last(), remember that those come AFTER the 
select() ... when you do select().first() you're really fetching all from 
the db and discarding all but one row.
 
The time difference may be negligible with a few records, but if you have 
lots of them, stick with limitby=(0,1) and orderby=field or orderby=~field

On Wednesday, March 27, 2013 10:34:25 PM UTC+1, Roberto Perdomo wrote:
>
> Sorry, the function must be return a string in order to concatenate with 
> the  filename
> El mar 27, 2013 4:59 PM, "Roberto Perdomo" > 
> escribió:
>
>> And what about something like this:
>>
>> Field('image_filename', readable=False, writable=False, compute = lambda 
>> row: request.post_vars.image.filename + next_id())
>>
>> def next_id():
>> last_row = db().select(db.table.id).last()
>> last_id = int(last_row[`table.id`])
>> return last_id + 1
>>
>> This was written from my cel phone and dont test it but  hope that helps 
>> ;-)
>>  El mar 27, 2013 3:25 PM, "Roberto Perdomo" 
>> > 
>> escribió:
>>
>>> :-S
>>> I was thinking on represent attribute from fields, not compute.
>>> El mar 27, 2013 3:07 PM, "Niphlod" > 
>>> escribió:
>>>
 boys . how can the id be present if what you're trying to insert is 
 not yet a row in a table 

 On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:
>
> Ummm, the id is readable?
>
> db.table.id.readable = True
> El mar 27, 2013 12:55 PM, "Tito Garrido"  
> escribió:
>
>> I just checked... id is not present:
>> "> b2754a53c6cdcc7e.**69626d2d4c6f676f2e6a7067.jpg', 'novela': '9', 
>> 'slug': '', 'descricao': ''}>"
>>
>>
>> On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo 
>> wrote:
>>
>>> Try:
>>>
>>> Field('image_filename', readable=False, writable=False, compute = 
>>> lambda row: request.post_vars.image.**filename + row.id),
>>> El mar 27, 2013 12:39 PM, "Tito Garrido"  
>>> escribió:
>>>
>>> How could I also append the id of the row in image_filename?

 Thanks!

 Tito


 On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido 
 wrote:

> Worked! It should go to the book :) http://web2py.com/books/**
> default/chapter/29/07#Storing-**the-original-filename
>
> Thanks!
>
> Tito
>
>
> On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
> massimo@gmail.com> wrote:
>
>> You can use this:
>>  Field('image_filename', readable=False, writable=False, compute 
>> = lambda row: request.post_vars.image.**filename),
>>
>>
>> On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:
>>>
>>> Hi!
>>>
>>> Why this does not work:
>>> Field('image', 'upload', requires=IS_NOT_EMPTY(), 
>>> uploadseparate=True, autodelete=True,),
>>> Field('image_filename', readable=False, writable=False, 
>>> compute = lambda row: row.image.filename),
>>>
>>> Using a form I can follow the book and fill the image filename:
>>> if request.vars.image!=None:
>>> try:
>>> form.vars.image_filename = 
>>> request.vars.image.filename
>>> except:
>>> form.vars.image_filename = request.vars.image
>>>
>>> How can I do the same using SQLFORM.grid?
>>>
>>> Regards,
>>>
>>> Tito
>>>
>>> -- 
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___ 
>>>
>>  -- 
>>  
>> --- 
>> You received this message because you are subscribed to the 
>> Google Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it, 
>> send an email to web2py+un...@**googlegroups.com.
>> For more options, visit https://groups.google.com/**
>> groups/opt_out .
>>  
>>  
>>
>
>
>
> -- 
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___ 
>



 -- 

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___ 

 -- 
  
 --- 
 You received this message because you are subscribed to the Google 
 Groups "web2py-users" group.
 To unsubscribe from this group and stop receiving emails

[web2py] Re: Auth with Janrain but still require "registration"

2013-03-27 Thread Anthony
Are you saying you want to be able to approve the registrations of users 
(so just logging in via Janrain isn't enough to allow access), or do you 
simply want to require users to add to their profile when they first log in 
with Janrain?

On Wednesday, March 27, 2013 4:08:42 PM UTC-4, DeanK wrote:
>
>
> So I want to be able to use Janrain, but I also want to have people have 
> to register.  For my app initially i need to control when registration is 
> open and when it is not, and currently using the examples i've seen, 
> enabling Janrain makes anyone who can authenticate with one of the third 
> party provides able to access the app and add an entry to auth_users.
>
> This is what did in db.py
>
> from gluon.contrib.login_methods.rpx_account import use_janrain
> auth.settings.actions_disabled=['change_password','request_reset_password']
> use_janrain(auth, filename='private/janrain.key')
>
> Once this is done auth works as descrived above, but the register button 
> disappears and /default/user/register/ throws a 404.
>
> Is there any way to still point to a registration page and make auth only 
> allow users who already exist when logging in via Janrain?  Ideally 
> /register would work and essentially after getting a token from Janrain it 
> would redirect to profile to add additional user info.
>
>
> Thanks,
> Dean
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Why compute does not work to get image filename?

2013-03-27 Thread Roberto Perdomo
Sorry, the function must be return a string in order to concatenate with
the  filename
El mar 27, 2013 4:59 PM, "Roberto Perdomo"  escribió:

> And what about something like this:
>
> Field('image_filename', readable=False, writable=False, compute = lambda
> row: request.post_vars.image.filename + next_id())
>
> def next_id():
> last_row = db().select(db.table.id).last()
> last_id = int(last_row[`table.id`])
> return last_id + 1
>
> This was written from my cel phone and dont test it but  hope that helps
> ;-)
>  El mar 27, 2013 3:25 PM, "Roberto Perdomo" 
> escribió:
>
>> :-S
>> I was thinking on represent attribute from fields, not compute.
>> El mar 27, 2013 3:07 PM, "Niphlod"  escribió:
>>
>>> boys . how can the id be present if what you're trying to insert is
>>> not yet a row in a table 
>>>
>>> On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:

 Ummm, the id is readable?

 db.table.id.readable = True
 El mar 27, 2013 12:55 PM, "Tito Garrido"  escribió:

> I just checked... id is not present:
> " b2754a53c6cdcc7e.**69626d2d4c6f676f2e6a7067.jpg', 'novela': '9',
> 'slug': '', 'descricao': ''}>"
>
>
> On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo 
> wrote:
>
>> Try:
>>
>> Field('image_filename', readable=False, writable=False, compute =
>> lambda row: request.post_vars.image.**filename + row.id),
>> El mar 27, 2013 12:39 PM, "Tito Garrido" 
>> escribió:
>>
>> How could I also append the id of the row in image_filename?
>>>
>>> Thanks!
>>>
>>> Tito
>>>
>>>
>>> On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido wrote:
>>>
 Worked! It should go to the book :) http://web2py.com/books/**
 default/chapter/29/07#Storing-**the-original-filename

 Thanks!

 Tito


 On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
 massimo@gmail.com> wrote:

> You can use this:
>  Field('image_filename', readable=False, writable=False, compute =
> lambda row: request.post_vars.image.**filename),
>
>
> On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:
>>
>> Hi!
>>
>> Why this does not work:
>> Field('image', 'upload', requires=IS_NOT_EMPTY(),
>> uploadseparate=True, autodelete=True,),
>> Field('image_filename', readable=False, writable=False,
>> compute = lambda row: row.image.filename),
>>
>> Using a form I can follow the book and fill the image filename:
>> if request.vars.image!=None:
>> try:
>> form.vars.image_filename = request.vars.image.filename
>> except:
>> form.vars.image_filename = request.vars.image
>>
>> How can I do the same using SQLFORM.grid?
>>
>> Regards,
>>
>> Tito
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to web2py+un...@**googlegroups.com.
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>



 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___

>>>
>>>
>>>
>>> --
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>  --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to web2py+un...@**googlegroups.com.
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> 

Re: [web2py] Re: Why compute does not work to get image filename?

2013-03-27 Thread Roberto Perdomo
And what about something like this:

Field('image_filename', readable=False, writable=False, compute = lambda
row: request.post_vars.image.filename + next_id())

def next_id():
last_row = db().select(db.table.id).last()
last_id = int(last_row[`table.id`])
return last_id + 1

This was written from my cel phone and dont test it but  hope that helps ;-)
 El mar 27, 2013 3:25 PM, "Roberto Perdomo"  escribió:

> :-S
> I was thinking on represent attribute from fields, not compute.
> El mar 27, 2013 3:07 PM, "Niphlod"  escribió:
>
>> boys . how can the id be present if what you're trying to insert is
>> not yet a row in a table 
>>
>> On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:
>>>
>>> Ummm, the id is readable?
>>>
>>> db.table.id.readable = True
>>> El mar 27, 2013 12:55 PM, "Tito Garrido"  escribió:
>>>
 I just checked... id is not present:
 ">>> b2754a53c6cdcc7e.**69626d2d4c6f676f2e6a7067.jpg', 'novela': '9',
 'slug': '', 'descricao': ''}>"


 On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo wrote:

> Try:
>
> Field('image_filename', readable=False, writable=False, compute =
> lambda row: request.post_vars.image.**filename + row.id),
> El mar 27, 2013 12:39 PM, "Tito Garrido" 
> escribió:
>
> How could I also append the id of the row in image_filename?
>>
>> Thanks!
>>
>> Tito
>>
>>
>> On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido wrote:
>>
>>> Worked! It should go to the book :) http://web2py.com/books/**
>>> default/chapter/29/07#Storing-**the-original-filename
>>>
>>> Thanks!
>>>
>>> Tito
>>>
>>>
>>> On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
>>> massimo@gmail.com> wrote:
>>>
 You can use this:
  Field('image_filename', readable=False, writable=False, compute =
 lambda row: request.post_vars.image.**filename),


 On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:
>
> Hi!
>
> Why this does not work:
> Field('image', 'upload', requires=IS_NOT_EMPTY(),
> uploadseparate=True, autodelete=True,),
> Field('image_filename', readable=False, writable=False,
> compute = lambda row: row.image.filename),
>
> Using a form I can follow the book and fill the image filename:
> if request.vars.image!=None:
> try:
> form.vars.image_filename = request.vars.image.filename
> except:
> form.vars.image_filename = request.vars.image
>
> How can I do the same using SQLFORM.grid?
>
> Regards,
>
> Tito
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>
  --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users" group.
 To unsubscribe from this group and stop receiving emails from it,
 send an email to web2py+un...@**googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .



>>>
>>>
>>>
>>> --
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___
>>>
>>
>>
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>> --
>>
>> ---
>> You received this message because you are subscribed to the Google
>> Groups "web2py-users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to web2py+un...@**googlegroups.com.
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>>
>>
>  --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to web2py+un...@**googlegroups.com.
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>



 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___

 --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users" group.
 To unsubscri

[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Niphlod
uhm... I didn't quite understand, but it seems that you want different 
things to happen when "printing" the url and when "accessing" the url.
Why is hard separating "printing a link" logic from the "accessing the 
link" one ?
It's a common "construct", i.e. on one page 

click here to "like" the image

and on another page

-
image
-
you "liked this image"

the second page, either accessed as a relative or as an absolute url, makes 
no difference from the web2py standpoint.

If I totally missed your requirements, can you give a "plain english" 
explanation on what you're trying to accomplish ?
PS: I'm on gtalk for the next hour if this requires a long digression :P

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: using a representation of an absolute URL to update a db?

2013-03-27 Thread Lamps902
In the case that I'm dealing with, the image is incidental to the problem. 
But let's say there is an image, and a relative URL (i.e. file download); 
you can do something like this:

db.my_db.file.represent = lambda x,y: \
A(generate_image(y.file),
_href=URL(args=["my_db/download", x],vars = 
dict(action="update_download_number", id=y.id)))

Can't do this for absolute links. Maybe I'm misunderstanding your 
suggestion, but the same image generator function will be invoked for all 
of the rows in the table, so if I use that, all the rows end up being 
updated, as opposed to the one which should be updated. So basically, I 
think it comes down to how to go about creating a function that's invoked 
when an absolute link is clicked, and passing an identifier related 
specifically to that link to the function.

On Wednesday, March 27, 2013 2:41:16 PM UTC-5, Niphlod wrote:
>
> so, you have an url (i.e. a string) that needs to return an image.
> you should have a controller that, when that URI is matched, returns the 
> image after increasing its number_visited value seems pretty standard 
> to me
>
> On Wednesday, March 27, 2013 7:15:12 PM UTC+1, Lamps902 wrote:
>>
>> Let's say you have an SQL grid generated from a db with field *my_url*, 
>> which stores the value of an absolute URL, and has a representation defined 
>> in this way: 
>>
>> db.my_db.my_url.represent = lambda the_url, row: A(generate_link_image(), 
>> _href=the_url, _target='_blank')
>>
>> What would be a good way to modify the above code so that when the link 
>> is clicked, some field in *my_db* (for example, *number_visited*, 
>> corresponding to the number of times the url has been clicked) is updated? 
>> I'm not sure you can use _href=URL(...) with absolute links, and other 
>> variants I've tried end up updating every record referenced in the table 
>> rather than just the one that the user clicks. Thanks.
>>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: scheduler sincronization

2013-03-27 Thread Niphlod
it was just a trial.
Explaining it further, let's see if someone spots the **supposed** 
implementation error

In order to separate transactions and avoid "task contention" among several 
workers, we need the **master** steps to both assign tasks and process 
tasks.

The **thread** steps inserts a virtual "assign the task" job setting the 
do_assign_task flag to True when necessary.
When that is found to be true, **worker** assigns tasks and sleeps for 3 
seconds, giving the change to the send_heartbeat() to reset the 
do_assign_task to False, so you don't have consecutive "assign_tasks" over 
and over.

Skipping over the actual steps taken, a **master** does a loop and sleeps. 

In that loop, if do_assign_task is True, it assign tasks, returns "None" 
--> goes to sleep for 3 seconds

A **thread** does some cleanup, sleeps for 3 seconds and sets the 
do_assign_task every 5 cycles.

Ok, to be fair it's not guaranteed that a loop in either of those completes 
in 3 seconds, but the **steps** for both (when the **worker** doesn't 
anything) take a few ms (i.e. scheduler doesn't take into account how many 
ms passed between the start of either loop before setting the sleep of 3 
seconds...)

So, self.sleep() in normal condition gets called:
- at every loop of the **thread** (at the end of the send_heartbeat())
- at every loop of the **master** when it has no tasks or when it assign 
tasks (at the end of the loop() function)  

What you are experiencing is that, even if the **thread** sets correctly 
do_assign_tasks = True, when the **worker** tries to pop something for some 
reason do_assign_task is False.
I can imagine that such a thing happens because do_assign_task is reset to 
False, but that reset happens only after (at least) 3 seconds, at the next 
send_heartbeat() call.
What I can't reproduce is this behaviour exactly how is it possible 
that in your logs the "I'm a ticker" message comes 40 ms before pop_task, 
and do_assign_task is yet False ?  
Can you add a logging line just between these two lines
self.do_assign_tasks = False
if counter % 5 == 0 or mybackedstatus == PICK:
and between
if self.worker_status[0] == ACTIVE:
self.do_assign_tasks = True

so we can monitor exactly when the flag is switched ?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Auth with Janrain but still require "registration"

2013-03-27 Thread DeanK

So I want to be able to use Janrain, but I also want to have people have to 
register.  For my app initially i need to control when registration is open 
and when it is not, and currently using the examples i've seen, enabling 
Janrain makes anyone who can authenticate with one of the third party 
provides able to access the app and add an entry to auth_users.

This is what did in db.py

from gluon.contrib.login_methods.rpx_account import use_janrain
auth.settings.actions_disabled=['change_password','request_reset_password']
use_janrain(auth, filename='private/janrain.key')

Once this is done auth works as descrived above, but the register button 
disappears and /default/user/register/ throws a 404.

Is there any way to still point to a registration page and make auth only 
allow users who already exist when logging in via Janrain?  Ideally 
/register would work and essentially after getting a token from Janrain it 
would redirect to profile to add additional user info.


Thanks,
Dean

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] Re: Why compute does not work to get image filename?

2013-03-27 Thread Roberto Perdomo
:-S
I was thinking on represent attribute from fields, not compute.
El mar 27, 2013 3:07 PM, "Niphlod"  escribió:

> boys . how can the id be present if what you're trying to insert is
> not yet a row in a table 
>
> On Wednesday, March 27, 2013 8:18:38 PM UTC+1, Roberto Perdomo wrote:
>>
>> Ummm, the id is readable?
>>
>> db.table.id.readable = True
>> El mar 27, 2013 12:55 PM, "Tito Garrido"  escribió:
>>
>>> I just checked... id is not present:
>>> ">> b2754a53c6cdcc7e.**69626d2d4c6f676f2e6a7067.jpg', 'novela': '9',
>>> 'slug': '', 'descricao': ''}>"
>>>
>>>
>>> On Wed, Mar 27, 2013 at 2:24 PM, Roberto Perdomo wrote:
>>>
 Try:

 Field('image_filename', readable=False, writable=False, compute =
 lambda row: request.post_vars.image.**filename + row.id),
 El mar 27, 2013 12:39 PM, "Tito Garrido"  escribió:

 How could I also append the id of the row in image_filename?
>
> Thanks!
>
> Tito
>
>
> On Mon, Mar 25, 2013 at 4:58 PM, Tito Garrido wrote:
>
>> Worked! It should go to the book :) http://web2py.com/books/**
>> default/chapter/29/07#Storing-**the-original-filename
>>
>> Thanks!
>>
>> Tito
>>
>>
>> On Mon, Mar 25, 2013 at 4:53 PM, Massimo Di Pierro <
>> massimo@gmail.com> wrote:
>>
>>> You can use this:
>>>  Field('image_filename', readable=False, writable=False, compute =
>>> lambda row: request.post_vars.image.**filename),
>>>
>>>
>>> On Monday, 25 March 2013 13:28:19 UTC-5, Tito Garrido wrote:

 Hi!

 Why this does not work:
 Field('image', 'upload', requires=IS_NOT_EMPTY(),
 uploadseparate=True, autodelete=True,),
 Field('image_filename', readable=False, writable=False, compute
 = lambda row: row.image.filename),

 Using a form I can follow the book and fill the image filename:
 if request.vars.image!=None:
 try:
 form.vars.image_filename = request.vars.image.filename
 except:
 form.vars.image_filename = request.vars.image

 How can I do the same using SQLFORM.grid?

 Regards,

 Tito

 --

 Linux User #387870
 .
  _/_õ|__|
 ..º[ .-.___.-._| . . . .
 .__( o)__( o).:___

>>>  --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>>
>> Linux User #387870
>> .
>>  _/_õ|__|
>> ..º[ .-.___.-._| . . . .
>> .__( o)__( o).:___
>>
>
>
>
> --
>
> Linux User #387870
> .
>  _/_õ|__|
> ..º[ .-.___.-._| . . . .
> .__( o)__( o).:___
>
> --
>
> ---
> You received this message because you are subscribed to the Google
> Groups "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to web2py+un...@**googlegroups.com.
> For more options, visit 
> https://groups.google.com/**groups/opt_out
> .
>
>
>
  --

 ---
 You received this message because you are subscribed to the Google
 Groups "web2py-users" group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to web2py+un...@**googlegroups.com.
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .



>>>
>>>
>>>
>>> --
>>>
>>> Linux User #387870
>>> .
>>>  _/_õ|__|
>>> ..º[ .-.___.-._| . . . .
>>> .__( o)__( o).:___
>>>
>>> --
>>>
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "web2py-users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to web2py+un...@**googlegroups.com.
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out
>>> .
>>>
>>>
>>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this messag

[web2py] Re: Image in web2py/MongoDB based blog

2013-03-27 Thread Alan Etkin


> Isn't there a way to put images using links from other storage websites in 
> the form? Because I'm not going to be the only administrating the site and 
> they won't know how to work with the thing in that first link
>

I think that you could use the new builtin wiki for allowing content 
management. You would still have to implement your own code for adding html 
with a wysiwyg, (I don't think it ships with the wiki feature). The wiki is 
also documented in the book here

http://www.web2py.com/books/default/chapter/29/03?search=auth.wiki#The-built-in-web2py-wiki

On the othe hand, If you plan to use a classic cms (i.e. letting users add 
and modify their own text and different media types), there are various 
ready to use apps that do it for you. If you type cms in the group search 
box, you'll find a lot of useful information on those apps. Two of them are 
Instant Press and Movuca (although Movuca is intended as a complete social 
network rather than a simple content management application). Also, there's 
a new web2py cms project recently announced in this group.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [web2py] App Go-Live Checklist

2013-03-27 Thread Richard Vézina
You have this for connection string :

try:
if request.env.http_host.split(':')[1]!='':
db=DAL('postgres://username:password@127.0.0.1:5432/database_name',
migrate_enabled=True, lazy_tables=True)
except Exception, e:
db=DAL('postgres://username:password@127.0.0.1:5432/database_name',
migrate_enabled=False, lazy_tables=True, pool_size=1)

I use pool_size=1 because I am with nginx, but I think that if you set
bigger number it make things faster with Apache...

Richard


On Wed, Mar 27, 2013 at 2:23 PM, Cliff Kachinske  wrote:

> I agree that indexing and connection pooling are the big hitters.
>
> My belief is that getting the connection is the big bottleneck in apps
> powered by a db.
>
> Smart indexing goes without saying, I think.
>
> On Wednesday, March 27, 2013 12:57:17 PM UTC-4, Jonathan Lundell wrote:
>
>> On 27 Mar 2013, at 9:46 AM, Derek  wrote:
>>
>> I was wondering if there is anything such as a "Go-Live Checklist" for
>> W2P apps. Like things you want to check before you go live, or
>> optimizations you can enable once your 'development' phase is done.
>>
>> For example:
>>
>> 1. Disable migrations
>> 2. Enable 'lazy tables'
>> 3. Enable DB Cache on queries
>> 4. Add @cache decorator to cacheable views.
>> 5. Add session.forget for methods which don't use the session object.
>> 6. Enable connection pooling depending on the database.
>>
>> Anyone have ideas on what to add to (or change in) the checklist? I
>> understand that not all developers can enable all optimizations, and you
>> should go through and test everything after you've "optimized" to make sure
>> the site still functions, but having this checklist as like a
>> pre-go-live-check might be a good thing to have for those of us who are
>> less experienced at deployments.
>>
>>
>>
>> compile the app
>> consider moving code to (imported) modules
>> controller-specific models
>> database indexes
>>
>> It'd be useful to try to attach order-of-magnitude
>> performance-improvement estimates to these things. I'd guess that caching
>> and optimal indexing would ordinarily be the big winners, though the
>> investment in some of them (disabling migrations, compiling the app, lazy
>> tables, connection pooling) is so small that they fall into the
>> why-would-you-not? category.
>>
>>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[web2py] Re: Populating jqGrid Tree with JSON

2013-03-27 Thread Willoughby
Oops - completely missed the 'no javascript' part.
It would appear it's not loading your jquery/jqgrid scripts.  Are you 
loading them in layout.html?
See this:

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:how_to_install

On Monday, March 25, 2013 6:51:10 PM UTC-4, Nate wrote:
>
> Nothing in the console. Firebug reports
>
> No Javascript on this pageIf  tags have a "type" attribute, it 
> should equal "text/javascript" or "application/javascript". Also scripts 
> must be parsable (syntactically correct).
>
>
> On Monday, March 25, 2013 11:15:31 PM UTC+11, Willoughby wrote:
>>
>> Do you get any errors in the console? That's the first place I usually 
>> look...
>>
>> On Sunday, March 24, 2013 8:42:45 PM UTC-4, Nate wrote:
>>>
>>> Hi
>>>
>>>  I have a controller sending JSON to my view. I cannot get the data into 
>>> the TreeGrid. The Json is coming down correctly (I placed it manually and 
>>> it works). Running this code places the JSON on the webpage. Controller and 
>>> View below.
>>>
>>> Help appreciated.
>>> Regards
>>> Nate
>>>
>>> CONTROLLER
>>> @service.json
>>> def get_report():
>>> import json
>>> 
>>> rows = db(db.neighbourhood.id > 0).select().as_list()
>>> concat = '{"response":['
>>> seq =1
>>> for row in rows:
>>> row['id'] = seq
>>> concat = concat + json.dumps(row)+","
>>> seq = seq+1
>>> innerrows = db(db.report.parent == 
>>> row.get('id')).select().as_list()
>>> for innerrow in innerrows:
>>> innerrow['id'] = seq
>>> concat = concat + json.dumps(innerrow) + ","
>>> seq = seq+1
>>> concat = concat.strip( ',' )
>>> concat = concat + ']},grid;'
>>> return concat
>>>
>>>
>>> VIEW
>>> {{extend 'layout.html'}}
>>>