Re: [web2py] Re: Mobile and Tablets detection

2013-07-17 Thread Angelo Compagnucci
Hi Marcio,

I'm planning to grow the supported mobile devices list in web2py, but the
support right now is fairly extensive.
I got the user agent strings here
http://www.useragentstring.com/pages/Mobile%20Browserlist/ and added at
least one of the devices for each family to the unit test of
gluon/contrib/user_agent_parser.py .

That class right now could discriminate between phone and tablets, so I
think you can't find somany differences with http://mobiledetect.net/ .

Sincerly,
Angelo

-- 
Profile: http://it.linkedin.com/in/compagnucciangelo

-- 

--- 
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] Implementing the download action in the manual's "images" tutorial application

2013-07-17 Thread REM
Hello, folks.

I started back at the top of the manual again and I am understanding much 
more by progressing slowly and with copious notes. So far, so good. 

However, I have come across a bit of a puzzling issue with the latter part 
of the "images" tutorial. After creating the dbases, uploading some images 
via appadmin, and then adding the app's core in default.py:

def index():
images = db().select(db.image.ALL, orderby=db.image.title)
return dict(images=images)


def show():
image = db.image(request.args(0,cast=int)) or redirect(URL('index'))
db.post.image_id.default = image.id
form = SQLFORM(db.post)
if form.process().accepted:
response.flash = 'your comment is posted'
comments = db(db.post.image_id==image.id).select()
return dict(image=image, comments=comments, form=form)


def download():
return response.download(request, db)







And then creating the default/index.html:

{{extend 'layout.html'}} 
Current Images 
 
{{for image in images:}} 
{{=LI(A(image.title, _href=URL("show", args=image.id)))}} 
{{pass}} 





And finally, the default/show.html:

{{extend 'layout.html'}}
Image: {{=image.title}}



{{if len(comments):}}
Comments
{{for post in comments:}}
{{=post.author}} says {{=post.body}}
{{pass}}
{{else:}}
No comments posted yet
{{pass}}
Post a comment
{{=form}}





When the app is called, it behaves as expected in every instance with one 
exception: I was figuring that, based on:





When the image was displayed in the show.html view, that maybe it would be 
tagged with an embedded download link such that passing the mouse over the 
image would indicate a link and then clicking the image would trigger a 
download action to download the image. This does not occur. The app just 
displays the uploaded image with no apparent way to download it (aside from 
the usual right-click browser options). In fact, in looking at the app's 
structure, I can't see where the download action in the default.py 
controller is ever triggered, since all of that =URL('download', 
args=image.file)}} doesn't *appear* to cause any action with regard to the 
requested image which is being displayed.

Through experimentation I discovered that I can indeed get a download 
action of the type which I *expected* to be triggered if I manually look up 
the name of the uploaded image file under 
applications/images/uploads/ and then pass it to the download 
action myself in the address bar:

http://localhost.../images/default/download/

That's what I was expecting to happen when I clicked on the image (or was 
somehow otherwise directed to the download action), but apparently I was 
wrong to assume this...?

In any case, how then does the download action get triggered if not by:





?

Any pointers, corrections, directions for further reading, etc. would be 
sincerely appreciated.

-- 

--- 
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: Mobile and Tablets detection

2013-07-17 Thread Niphlod
ok, you're fond of that php library. But did you take a closer look to what 
you have right in web2py using request.user_agent() ?
web2py uses gluon/contrib/user_agent_parser.py to fill up those fields 
and it does the exact same thing!

Il giorno giovedì 18 luglio 2013 01:05:11 UTC+2, Marcio Andrey Oliveira ha 
scritto:
>
> Hi.
>
> Thank you for replying.
>
> I really don't know all user agents and I prefer to rely on a library that 
> automatically detects whether the users is browsing from a regular 
> computer, a mobile or a tablet. The greatest benefit (IMHO) from 
> mobiledetect is that it's regularly updated to incorporate new devices.
>
> If you take a look at mobile detect source code you will see that are 
> around 1,300 devices up to now.
>
> I thought I could try to convert its code from PHP to python but as I'm 
> not that good on python I wondered if someone in python community have made 
> a similar library / module.
>
> Regards.
>
> On Wednesday, July 17, 2013 3:12:47 PM UTC-3, Marcio Andrey Oliveira wrote:
>>
>> Hi.
>>
>> I'm wondering whether exists a python project that detect mobiles and 
>> tables that be as good and as up to date as http://mobiledetect.net/
>>
>> 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] Crash Course in web2py. I get this error, but I can't fix it

2013-07-17 Thread jayvandal
I am tryin Form part 3 Crash Course iinweb2py. I get this error, but I 
can't fix it

failed to compile file because:
SyntaxError at line 1 at char 21
invalid syntax (C:/web2py/applications/form/views/display_your_form.py, 
line 1)
×
Editing file "form/views/
next line is line 1
{{extend 'layout.html'}}

Web Form

Please enter your first and last names, and email address.
Please note: All attempts must be error free before any info is 
accepted.
Inputs:
{ {=form}}
Submitted Fields:
{ {=BEAUTIFY(request.vars)}}
Accepted Fields:
{ {=BEAUTIFY(form.vars)}}
Errors:
{ {=BEAUTIFY(form.errors)}}

-- 

--- 
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: Deadlock found when trying to get lock; try restarting transaction

2013-07-17 Thread vince
actually yes i just need a way to handle this error myself. see the above 
for the error message i attached, the sample from you didn't work.


On Thursday, July 18, 2013 6:56:27 AM UTC+8, Alan Etkin wrote:
>
> those ticket don't come with request/session info, we have no idea where 
>> and when did this problem occur. does that mean that web2py already handle 
>> the retry?
>>
>  
> AFAIK, web2py does not retry db I/O commands. The tickets are created when 
> the request generates an uncaught exception (in your case, a driver error). 
> One way of preventing this would be writing your own driver error (and 
> retry) handler in your application logic.
>
> I guess something like this
>
> def action():
> from adriver import DriverException
> try:
> rows = ...
> except DriverException:
> raise HTTP(500, "Seems like the cluster is busy now. Try in a few 
> moments")
> return dict(...) 
>
>

-- 

--- 
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] What is the syntax problem with this autocomplete widget statement?

2013-07-17 Thread Alex Glaros
The error is that the field stays blank and doesn't display any choices.

## -
db.define_table('ObjectSuperType', ## Lookup table
Field('objectDisplayName','string', label='Object Name'), 
format='%(objectDisplayName)s') 
## -
db.define_table('Interoperability', ## Parent table. This connects 
different already-existing objectIDs. 
Field('shortInteroperabilityTitle', 'string'))  
## -
db.define_table('InteroperabilityDetail', ## Child table. This is where the 
world can identify components under a interoperabilityID (1:M) so that 
ideas are crowdsourced from everywhere. 
Field('interoperabilityID', 'reference Interoperability'), 
Field('objectID', 'reference ObjectSuperType')) 
## ^
db.InteroperabilityDetail.objectID.widget = 
SQLFORM.widgets.autocomplete(request, db.ObjectSuperType.objectDisplayName, 
id_field=db.ObjectSuperType.id)
db.InteroperabilityDetail.interoperabilityID.requires = IS_IN_DB(db, 
'Interoperability.id', '%(shortInteroperabilityTitle)s',zero=T('choose 
one'))
db.InteroperabilityDetail.interoperabilityID.represent = lambda id,row: 
db.Interoperability(id).shortInteroperabilityTitle
##db.InteroperabilityDetail.objectID.requires = IS_IN_DB(db, 
'ObjectSuperType.id', '%(objectDisplayName)s',zero=T('choose one')) ##Does 
this line interfere with autocomplete?
##db.InteroperabilityDetail.objectID.represent = lambda id,row: 
db.ObjectSuperType(id).objectDisplayName 

Thanks,

Alex Glaros

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Sarbjit singh
Thanks guys for the help.

I followed the approach as suggested by Massimo, so I did the following :

@auth.requires_login()  
def search2():
form,results = dynamic_search(db.customer)
if form.process().accepted:
session.results = results
redirect(URL('results'))
return dict(form=form)

@auth.requires_login() 
def results():
results = session.results
return dict(results=results)

Please note that the dynamic_search is returning grid and form, so I am 
storing grid in the  form.


But I am still facing problems, not sure what wrong steps I am doing. For 
the first time, when I click on search, desired results are opened in 
controller "results" (in a new page). But when I click on edit/view of grid 
operation, some how the page gets redirected to "search" page and on 
subsequent search it crashes with the same problem (can't pickle ..). My 
question is when i click on edit operations on a grid, why it is 
redirecting to search. Isn't it is supposed to open edit form there itself?

Thanks
Sarbjit
 
On Thursday, July 18, 2013 1:00:12 AM UTC+5:30, Dmitri Husti wrote:
>
> Hi,
> Is it possible to pass the request vars and call the function 
> dynamic_search twice?
> redirect(URL("test",vars=request.vars))
>
>
>
> Am Mittwoch, 17. Juli 2013 18:46:07 UTC+2 schrieb Massimo Di Pierro:
>>
>> You can store the results in session then.
>>
>> session.rows = db(...).select()
>>
>> Passing to much data in request.vars can be a problem. For example nginx 
>> limits the size of the query string.
>>
>>
>>
>>
>> On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote:
>>>
>>> HI,
>>> you can pass results to the next page;
>>> redirect(URL("test",vars=dict(results=results))
>>>
>>> On the next page you can do 
>>> return dict(results=request.vars["results"])
>>>
>>> Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh:

 Hi,

 I am trying to use "dynamic search form" from 
 http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
 implementation shows both the form and results on the same page.

 I want to display the search results (using GRID) in a new page and 
 wants to use customized forms for edit/view operations associated with 
 GRID.

 As of now, I tried handling it in the view to not to show form contents 
 once the form is accessed but some how it is not working on subsequent 
 operations.

 So, I am thinking to pass query to a new controller and can hence 
 handle the custom forms there. But I am not able to do so.

 So here is what I tried :

 @auth.requires_login()  
 def search2():
 form,query = dynamic_search(db.customer)
 if form.process().accepted:
 session.sqlquery = query
 redirect(URL('results'))
 return dict(form=form)

 @auth.requires_login() 
 def results():
 query = session.sqlquery
 print query
 results =  
 SQLFORM.grid(query,searchable=False,create=False,csv=False)
 results = None
 return dict(results=results)

 With this code, first error that is encountered is in "session.sqlquery 
 = query" -> Can't pickle objects 

 So I modified it as 

 session.sqlquery = str(query)

 With this error appeared in "query = session.sqlquery" -> str object 
 has no attribute _db

 Can some one please suggest what is the right way to achieve this?

 -Sarbjit



-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Woody
Ok, here's the format for my select and table creation: 

In the controller:

rows = db_mydb(db_mydb.my_table).select()
fields = db_mydb.my_table.fields
headers = [list of headers]

table = TABLE(THEAD(TR(*[B(header) for header in headers])),
 TBODY(*[TR(*[TD(row[field]) for field in fields]) \
for row in rows]))
table["_class"] = "table table-striped table-bordered table-condensed"
return dict(table=table)

In the view:


{{=LOAD('default','my_table_function',ajax=True, target='table')}}




On Wednesday, July 17, 2013 11:10:35 PM UTC-4, Richard wrote:
>
> Can you show us you select and the way you make your table and view?
>
> Richard
>
>
> On Wed, Jul 17, 2013 at 11:02 PM, Woody  >wrote:
>
>> I don't see 'This is a test'.  The table looks exactly the same as it 
>> does without the represent statement.
>>
>> It doesn't matter what I put in the represent statement, If I have:
>>
>> db_mydb.my_table.location.**represent=lambda location,row: XML(T('This 
>> is a test'))
>>
>> 'This is a test' doesn't appear in the table.
>>
>> It also doesn't work if I put:
>>
>> db_mydb.my_table.location.**represent=lambda location,row:T('This is a 
>> test').
>>
>> No matter what I put in the represent statement, my table looks the same. 
>>  I'm obviously doing something wrong, but I can't figure out what it is.
>>
>>
>> On Wednesday, July 17, 2013 7:34:13 PM UTC-4, Richard wrote:
>>
>>> I don't understand... Do you see : This is a test ?? You don't need 
>>> XML() for use a simple T(), XML serve to escape special caracter and 
>>> accentuated one, at least that my understanding. And of course there will 
>>> be not change (all your value will be represent with : This is a test, 
>>> since you don't take care of your location in your lambda.
>>>
>>> I never try to pass html tag in a represent except a A() helper, but I 
>>> don't why it would not work.
>>>
>>> You don't really need XML in the code above (virtual field), try this :
>>>
>>> Field.Virtual('description_**for**matted', lambda row: 
>>> SPAN(row.description, _style="color:#EB0F0F;"), 
>>>
>>> or 
>>>
>>> Field.Virtual('description_**for**matted', lambda row: 
>>> TAG.span(row.description, _style="color:#EB0F0F;"),  
>>>
>>> In case there is no SPAN helper (don't remember if there is SPAN() 
>>> helper).
>>>
>>> Richard
>>>  
>>>
>>> On Wed, Jul 17, 2013 at 5:55 PM, Woody  wrote:
>>>
 'represent' is not working for me.  Here's my code:

 ---
 db_mydb.define_table('my_**table',
 Field('ROWID', 'id'),
 Field('location', 'string'),
 Field('other_field', 'string'),
 migrate=False)

 db_mydb.my_table.location.**represent=lambda location,row: XML(T('This 
 is a test'))
 

 Doesn't matter what I put in the represent declaration, the data 
 displayed in the table doesn't change.








 On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:

> represent!!
>
> represent=lambda value, row: XML(...) if value is not None else 
> T('N/A')
>
> Richard
>
>
>  On Wed, Jul 17, 2013 at 3:24 PM, Woody  wrote:
>
>> I have a table definition that uses virtual fields with XML:
>>
>> db_mydb.define_table('my_**table**',
>> Field('ROWID', 'id'),
>> Field('location', 'string'),
>> Field('description', 'string', required=False),
>> Field.Virtual('description_**for**matted', lambda 
>> row: XML('' + row.description + ''), 
>> etc
>>
>> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is 
>> there a way to do this without having to create a virtual field?  In 
>> other 
>> words, I'd like to be able to add HTML formatting in a normal field 
>> definition, using XML or helper functions.
>>
>>  -- 
>>  
>> --- 
>> 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
>> .
>>  
>>  
>>
>
>  -- 
  
 --- 
 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 Goog

Re: [web2py] Inject HTML in field definition

2013-07-17 Thread Richard Vézina
Can you show us you select and the way you make your table and view?

Richard


On Wed, Jul 17, 2013 at 11:02 PM, Woody  wrote:

> I don't see 'This is a test'.  The table looks exactly the same as it does
> without the represent statement.
>
> It doesn't matter what I put in the represent statement, If I have:
>
> db_mydb.my_table.location.**represent=lambda location,row: XML(T('This is
> a test'))
>
> 'This is a test' doesn't appear in the table.
>
> It also doesn't work if I put:
>
> db_mydb.my_table.location.**represent=lambda location,row:T('This is a
> test').
>
> No matter what I put in the represent statement, my table looks the same.
>  I'm obviously doing something wrong, but I can't figure out what it is.
>
>
> On Wednesday, July 17, 2013 7:34:13 PM UTC-4, Richard wrote:
>
>> I don't understand... Do you see : This is a test ?? You don't need XML()
>> for use a simple T(), XML serve to escape special caracter and accentuated
>> one, at least that my understanding. And of course there will be not change
>> (all your value will be represent with : This is a test, since you don't
>> take care of your location in your lambda.
>>
>> I never try to pass html tag in a represent except a A() helper, but I
>> don't why it would not work.
>>
>> You don't really need XML in the code above (virtual field), try this :
>>
>> Field.Virtual('description_**for**matted', lambda row:
>> SPAN(row.description, _style="color:#EB0F0F;"),
>>
>> or
>>
>> Field.Virtual('description_**for**matted', lambda row:
>> TAG.span(row.description, _style="color:#EB0F0F;"),
>>
>> In case there is no SPAN helper (don't remember if there is SPAN()
>> helper).
>>
>> Richard
>>
>>
>> On Wed, Jul 17, 2013 at 5:55 PM, Woody  wrote:
>>
>>> 'represent' is not working for me.  Here's my code:
>>>
>>> ---
>>> db_mydb.define_table('my_**table',
>>> Field('ROWID', 'id'),
>>> Field('location', 'string'),
>>> Field('other_field', 'string'),
>>> migrate=False)
>>>
>>> db_mydb.my_table.location.**represent=lambda location,row: XML(T('This
>>> is a test'))
>>> 
>>>
>>> Doesn't matter what I put in the represent declaration, the data
>>> displayed in the table doesn't change.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:
>>>
 represent!!

 represent=lambda value, row: XML(...) if value is not None else T('N/A')

 Richard


  On Wed, Jul 17, 2013 at 3:24 PM, Woody  wrote:

> I have a table definition that uses virtual fields with XML:
>
> db_mydb.define_table('my_**table**',
> Field('ROWID', 'id'),
> Field('location', 'string'),
> Field('description', 'string', required=False),
> Field.Virtual('description_**for**matted', lambda
> row: XML('' + row.description + ''),
> etc
>
> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is
> there a way to do this without having to create a virtual field?  In other
> words, I'd like to be able to add HTML formatting in a normal field
> definition, using XML or helper functions.
>
>  --
>
> ---
> 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
> .
>
>
>

  --
>>>
>>> ---
>>> 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 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] Inner join and left join in a many to many relationship

2013-07-17 Thread Mark Li
I have an intermediate table representing a many to many relationship 
between users and songs. Users can like/dislike many songs, and songs can 
be liked/disliked by many users. I am trying to retrieve a list of 30 
songs, that can be any songs except for songs that have been disliked by 
the user.

Here's a simplified version of the 3 tables:

#Table 1: 
db.define_table('auth_user',
Field('id')
)

#Table 2:
db.define_table('songs',
Field('id')
)

#Table 3 (intermediate)
db.define_table('likes_and_dislikes',
Field('username', 'reference auth_user'),
Field('songname','reference songs'),
Field('like_score', 'integer')
)



Originally I had made 2 database selects to accomplish this, first finding 
all the songs that have been disliked by the user (this can be a very high 
number), and then querying songs to avoid the disliked songs:

disliked_ids = []
dislike_query = (db.likes.username==auth.user.id) & (db.likes.like_score==-1
) #score of -1 represents a dislike
disliked_songs = db(dislike_query).select().as_list()
for row in disliked_songs:
disliked_ids.append(row['songname'])

query = (~db.songinfo.id.belongs(disliked_ids))
song_rows = db(pre_query).select(orderby='', limitby=(0,30))


I'm sure there's a more efficient way to do this, and I have been looking 
into left joins and inner joins to accomplish everything in one database 
select. My understanding of joins get a little hazy once there needs to be 
more than join performed, any help is appreciated!



-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Woody
I don't see 'This is a test'.  The table looks exactly the same as it does 
without the represent statement.

It doesn't matter what I put in the represent statement, If I have:

db_mydb.my_table.location.represent=lambda location,row: XML(T('This is a 
test'))

'This is a test' doesn't appear in the table.

It also doesn't work if I put:

db_mydb.my_table.location.represent=lambda location,row:T('This is a test').

No matter what I put in the represent statement, my table looks the same. 
 I'm obviously doing something wrong, but I can't figure out what it is.


On Wednesday, July 17, 2013 7:34:13 PM UTC-4, Richard wrote:
>
> I don't understand... Do you see : This is a test ?? You don't need XML() 
> for use a simple T(), XML serve to escape special caracter and accentuated 
> one, at least that my understanding. And of course there will be not change 
> (all your value will be represent with : This is a test, since you don't 
> take care of your location in your lambda.
>
> I never try to pass html tag in a represent except a A() helper, but I 
> don't why it would not work.
>
> You don't really need XML in the code above (virtual field), try this :
>
> Field.Virtual('description_**formatted', lambda row: 
> SPAN(row.description, _style="color:#EB0F0F;"), 
>
> or 
>
> Field.Virtual('description_**formatted', lambda row: 
> TAG.span(row.description, _style="color:#EB0F0F;"),  
>
> In case there is no SPAN helper (don't remember if there is SPAN() helper).
>
> Richard
>
>
> On Wed, Jul 17, 2013 at 5:55 PM, Woody  >wrote:
>
>> 'represent' is not working for me.  Here's my code:
>>
>> ---
>> db_mydb.define_table('my_table',
>> Field('ROWID', 'id'),
>> Field('location', 'string'),
>> Field('other_field', 'string'),
>> migrate=False)
>>
>> db_mydb.my_table.location.represent=lambda location,row: XML(T('This is a 
>> test'))
>> 
>>
>> Doesn't matter what I put in the represent declaration, the data 
>> displayed in the table doesn't change.
>>
>>
>>
>>
>>
>>
>>
>>
>> On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:
>>
>>> represent!!
>>>
>>> represent=lambda value, row: XML(...) if value is not None else T('N/A')
>>>
>>> Richard
>>>
>>>
>>>  On Wed, Jul 17, 2013 at 3:24 PM, Woody  wrote:
>>>
 I have a table definition that uses virtual fields with XML:

 db_mydb.define_table('my_**table',
 Field('ROWID', 'id'),
 Field('location', 'string'),
 Field('description', 'string', required=False),
 Field.Virtual('description_**formatted', lambda row: 
 XML('' + row.description + ''), 
 etc

 So, using Field.Virtual, I can pass XML with HTML tags to a table. Is 
 there a way to do this without having to create a virtual field?  In other 
 words, I'd like to be able to add HTML formatting in a normal field 
 definition, using XML or helper functions.

  -- 
  
 --- 
 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.
>>  
>>  
>>
>
>

-- 

--- 
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: Crud.update returning none

2013-07-17 Thread Karel Antonio Verdecia Ortiz

I think you forgot to return locals:

def project_edit():
project = db.projects.request.args(0)
form = crud.update(db.projects, project , next='projects')
*return locals()*

def user_edit():
user = db.users(request.args(0))
form = crud.update(db.users, user, next = 'users')
*return locals()*



El 17/07/13 15:51, Alan Etkin escribió:

def project_edit():
project = db.projects.request.args(0)
print project
form = crud.update(db.projects, project , next='projects')

def user_edit():
user = db.users(request.args(0))
print user
form = crud.update(db.users, user, next = 'users')

Try this new functions and tell us what you see at the console output 
when you open those actions.


For more advanced debugging cosider using the built-in feature
http://www.web2py.com/books/default/chapter/29/03?search=debugger

--

---
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: Micro-framework performance vs Web2py?

2013-07-17 Thread Tim Richardson
I guess it's an obvious point, but you also need to consider developer 
productivity (which is the reason we code in Python and not assembly). 
It's almost miraculous what one can do with web2py and a couple of hours. 

-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Richard Vézina
I don't understand... Do you see : This is a test ?? You don't need XML()
for use a simple T(), XML serve to escape special caracter and accentuated
one, at least that my understanding. And of course there will be not change
(all your value will be represent with : This is a test, since you don't
take care of your location in your lambda.

I never try to pass html tag in a represent except a A() helper, but I
don't why it would not work.

You don't really need XML in the code above (virtual field), try this :

Field.Virtual('description_**formatted', lambda row: SPAN(row.description, _
style="color:#EB0F0F;"),

or

Field.Virtual('description_**formatted', lambda row:
TAG.span(row.description, _style="color:#EB0F0F;"),

In case there is no SPAN helper (don't remember if there is SPAN() helper).

Richard


On Wed, Jul 17, 2013 at 5:55 PM, Woody  wrote:

> 'represent' is not working for me.  Here's my code:
>
> ---
> db_mydb.define_table('my_table',
> Field('ROWID', 'id'),
> Field('location', 'string'),
> Field('other_field', 'string'),
> migrate=False)
>
> db_mydb.my_table.location.represent=lambda location,row: XML(T('This is a
> test'))
> 
>
> Doesn't matter what I put in the represent declaration, the data displayed
> in the table doesn't change.
>
>
>
>
>
>
>
>
> On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:
>
>> represent!!
>>
>> represent=lambda value, row: XML(...) if value is not None else T('N/A')
>>
>> Richard
>>
>>
>> On Wed, Jul 17, 2013 at 3:24 PM, Woody  wrote:
>>
>>> I have a table definition that uses virtual fields with XML:
>>>
>>> db_mydb.define_table('my_**table',
>>> Field('ROWID', 'id'),
>>> Field('location', 'string'),
>>> Field('description', 'string', required=False),
>>> Field.Virtual('description_**formatted', lambda row:
>>> XML('' + row.description + ''),
>>> etc
>>>
>>> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is
>>> there a way to do this without having to create a virtual field?  In other
>>> words, I'd like to be able to add HTML formatting in a normal field
>>> definition, using XML or helper functions.
>>>
>>>  --
>>>
>>> ---
>>> 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 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: Mobile and Tablets detection

2013-07-17 Thread Marcio Andrey Oliveira
Hi.

Thank you for replying.

I really don't know all user agents and I prefer to rely on a library that 
automatically detects whether the users is browsing from a regular 
computer, a mobile or a tablet. The greatest benefit (IMHO) from 
mobiledetect is that it's regularly updated to incorporate new devices.

If you take a look at mobile detect source code you will see that are 
around 1,300 devices up to now.

I tough I could try to convert its code from PHP to python but as I'm not 
that good on python I wondered if someone in python community have made a 
similar library / module.

Regards.

On Wednesday, July 17, 2013 3:12:47 PM UTC-3, Marcio Andrey Oliveira wrote:
>
> Hi.
>
> I'm wondering whether exists a python project that detect mobiles and 
> tables that be as good and as up to date as http://mobiledetect.net/
>
> 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: Deadlock found when trying to get lock; try restarting transaction

2013-07-17 Thread Alan Etkin

>
> those ticket don't come with request/session info, we have no idea where 
> and when did this problem occur. does that mean that web2py already handle 
> the retry?
>
 
AFAIK, web2py does not retry db I/O commands. The tickets are created when 
the request generates an uncaught exception (in your case, a driver error). 
One way of preventing this would be writing your own driver error (and 
retry) handler in your application logic.

I guess something like this

def action():
from adriver import DriverException
try:
rows = ...
except DriverException:
raise HTTP(500, "Seems like the cluster is busy now. Try in a few 
moments")
return dict(...) 

-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Woody
'represent' is not working for me.  Here's my code:

---
db_mydb.define_table('my_table',
Field('ROWID', 'id'),
Field('location', 'string'),
Field('other_field', 'string'),
migrate=False)

db_mydb.my_table.location.represent=lambda location,row: XML(T('This is a 
test'))


Doesn't matter what I put in the represent declaration, the data displayed 
in the table doesn't change.








On Wednesday, July 17, 2013 3:34:21 PM UTC-4, Richard wrote:
>
> represent!!
>
> represent=lambda value, row: XML(...) if value is not None else T('N/A')
>
> Richard
>
>
> On Wed, Jul 17, 2013 at 3:24 PM, Woody  >wrote:
>
>> I have a table definition that uses virtual fields with XML:
>>
>> db_mydb.define_table('my_table',
>> Field('ROWID', 'id'),
>> Field('location', 'string'),
>> Field('description', 'string', required=False),
>> Field.Virtual('description_formatted', lambda row: 
>> XML('' + row.description + ''), 
>> etc
>>
>> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is 
>> there a way to do this without having to create a virtual field?  In other 
>> words, I'd like to be able to add HTML formatting in a normal field 
>> definition, using XML or helper functions.
>>
>>  -- 
>>  
>> --- 
>> 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.




[web2py] Re: Mobile and Tablets detection

2013-07-17 Thread Niphlod
whoops. request.user_agent()

On Wednesday, July 17, 2013 11:50:10 PM UTC+2, Niphlod wrote:
>
> because response.user_agent doesn't work for you ?
>
> On Wednesday, July 17, 2013 8:12:47 PM UTC+2, Marcio Andrey Oliveira wrote:
>>
>> Hi.
>>
>> I'm wondering whether exists a python project that detect mobiles and 
>> tables that be as good and as up to date as http://mobiledetect.net/
>>
>> 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: Mobile and Tablets detection

2013-07-17 Thread Niphlod
because response.user_agent doesn't work for you ?

On Wednesday, July 17, 2013 8:12:47 PM UTC+2, Marcio Andrey Oliveira wrote:
>
> Hi.
>
> I'm wondering whether exists a python project that detect mobiles and 
> tables that be as good and as up to date as http://mobiledetect.net/
>
> 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: Function for downloading files

2013-07-17 Thread lesssugar
Thanks Alan!

On Wednesday, July 17, 2013 10:05:14 PM UTC+2, Alan Etkin wrote:
>
>
>> def download_file():
>> file = db(db.files.user_id == int(request.args(0))).select()
>> for f in file:
>> name = f.name
>>  return response.download(name,db)
>>
>> I think that the call to download should be response.download(request, 
> db) and you could customize the request args so the method gets the file 
> you want:
>
> file = db(...).select().first().name
> request.args[-1] = name
> return response.download(request, db)
>
> Edit:
>
> request.args[-1] = name
>
> should be
>
> request.args[-1] = file
>

-- 

--- 
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: Deadlock found when trying to get lock; try restarting transaction

2013-07-17 Thread Niphlod
ehm, sorry. are you blaming web2py or the galera cluster ? web2py doesn't 
do anything special unless sending SQL queries down the pipe. If your 
galera cluster goes into deadlocks executing queries, fix the cluster ^_^

-- 

--- 
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: Deadlock found when trying to get lock; try restarting transaction

2013-07-17 Thread vince
i am using mariadb galera cluster and we did not implement any locking. 
been testing this cluster for long and it will return locking error during 
node lag.

heres the error i got.
Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.

Traceback (most recent call last):
  File "/home/web2py/gluon/main.py", line 599, in wsgibase
BaseAdapter.close_all_instances('commit')
  File "/home/web2py/gluon/dal.py", line 560, in close_all_instances
db._adapter.close(action)
  File "/home/web2py/gluon/dal.py", line 540, in close
getattr(self, action)()
  File "/home/web2py/gluon/dal.py", line 1740, in commit
if self.connection: return self.connection.commit()
  File "/home/web2py/gluon/contrib/pymysql/connections.py", line 631, in commit
self.errorhandler(None, exc, value)
  File "/home/web2py/gluon/contrib/pymysql/connections.py", line 202, in 
defaulterrorhandler
raise errorclass, errorvalue
InternalError: (1213, u'Deadlock found when trying to get lock; try restarting 
transaction')

In file: Framework


On Wednesday, July 17, 2013 5:27:30 PM UTC+8, Massimo Di Pierro wrote:
>
> We need more information. What is galera cluster? What you trying to lock?
>
> On Tuesday, 16 July 2013 22:29:09 UTC-5, vince wrote:
>>
>> we are testing web2py with galera cluster and notice lots of Deadlock 
>> found when trying to get lock; try restarting transaction ticket.
>>
>> those ticket don't come with request/session info, we have no idea where 
>> and when did this problem occur. does that mean that web2py already handle 
>> the retry?
>>
>

-- 

--- 
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: Relative links inside builtin wiki pages

2013-07-17 Thread peibol
Thanks!

But... then is no way to escape the markmin in the wiki pages to embed some 
python code or javascript?

Now I'm thinking for example to load some google chart images (javascript). 
Perhaps I shouldn't wikify my app and remain in multiple views, so they 
allow everything. However, I'd lose the management ease of such pages.


El miércoles, 17 de julio de 2013 21:49:19 UTC+2, dhmorgan escribió:
>
> you can, in your controller, call auth.wiki() with your needed variables:
>
> return auth.wiki(env=dict(host=lambda h:request.env.http_host,islocal= 
> lambda l:request.is_local)
>
> and in the wiki page body, use @{host:} to construct your link:
>
> [[ @{host:/someapp/some/path} ]]
>
> this works for me, though I'd like to be able to do the same with 
> wiki-menu; even though the above example renders correctly in wiki-menu's 
> page view, it gets mangled in the drop-down menu itself.
>
>
> On Wednesday, July 17, 2013 6:40:29 AM UTC-5, peibol wrote:
>>
>> Hi there, simple question... I'd like to embed links inside the wiki 
>> pages to some views of my application. Is it possible to use some kind of 
>> helper, or to embed python expressions in {{}} in order to avoid writing 
>> absolute urls (which are different in localhost development and maybe 
>> dependent of deployment)
>> Thanks
>> Pablo
>>
>

-- 

--- 
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: Function for downloading files

2013-07-17 Thread Alan Etkin

>
>
> def download_file():
> file = db(db.files.user_id == int(request.args(0))).select()
> for f in file:
> name = f.name
>  return response.download(name,db)
>
> I think that the call to download should be response.download(request, db) 
and you could customize the request args so the method gets the file you 
want:

file = db(...).select().first().name
request.args[-1] = name
return response.download(request, db)

-- 

--- 
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: Crud.update returning none

2013-07-17 Thread Alan Etkin
def project_edit():
project = db.projects.request.args(0)
print project
form = crud.update(db.projects, project , next='projects')

def user_edit():
user = db.users(request.args(0)) 
print user
form = crud.update(db.users, user, next = 'users')

Try this new functions and tell us what you see at the console output when 
you open those actions.

For more advanced debugging cosider using the built-in feature
http://www.web2py.com/books/default/chapter/29/03?search=debugger

-- 

--- 
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: Relative links inside builtin wiki pages

2013-07-17 Thread dhmorgan
you can, in your controller, call auth.wiki() with your needed variables:

return auth.wiki(env=dict(host=lambda h:request.env.http_host,islocal= 
lambda l:request.is_local)

and in the wiki page body, use @{host:} to construct your link:

[[ @{host:/someapp/some/path} ]]

this works for me, though I'd like to be able to do the same with 
wiki-menu; even though the above example renders correctly in wiki-menu's 
page view, it gets mangled in the drop-down menu itself.


On Wednesday, July 17, 2013 6:40:29 AM UTC-5, peibol wrote:
>
> Hi there, simple question... I'd like to embed links inside the wiki pages 
> to some views of my application. Is it possible to use some kind of helper, 
> or to embed python expressions in {{}} in order to avoid writing absolute 
> urls (which are different in localhost development and maybe dependent of 
> deployment)
> Thanks
> Pablo
>

-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Richard Vézina
represent!!

represent=lambda value, row: XML(...) if value is not None else T('N/A')

Richard


On Wed, Jul 17, 2013 at 3:24 PM, Woody  wrote:

> I have a table definition that uses virtual fields with XML:
>
> db_mydb.define_table('my_table',
> Field('ROWID', 'id'),
> Field('location', 'string'),
> Field('description', 'string', required=False),
> Field.Virtual('description_formatted', lambda row:
> XML('' + row.description + ''),
> etc
>
> So, using Field.Virtual, I can pass XML with HTML tags to a table. Is
> there a way to do this without having to create a virtual field?  In other
> words, I'd like to be able to add HTML formatting in a normal field
> definition, using XML or helper functions.
>
>  --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 

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




Re: [web2py] web2py roadmap

2013-07-17 Thread Niphlod
try on the extended one 

https://trello.com/b/d3aqBbBl/web2py-roadmap

On Wednesday, July 17, 2013 9:06:16 PM UTC+2, greaneym wrote:
>
> Hi,
>
> I get a blank screen also on that url link.
>
> margaret
>
> On Tuesday, July 16, 2013 11:10:32 AM UTC-5, jjs0sbw wrote:
>>
>> I get a blank screen???
>>
>>
>> On Sun, Jul 14, 2013 at 1:30 PM, Niphlod  wrote:
>>
>>> web2py's developers work often "behind the curtain" and users are not 
>>> able to see what they're working on. Historically we tracked down 
>>> feature-requests and todo-lists on google code, but it's a nightmare to 
>>> track them and work with it efficiently.
>>>
>>> On a nice tip received by a power web2py user, we (developers) decided 
>>> to create something more readable to give us (developers AND users) a nice 
>>> representation on what's going on.
>>>
>>> Please welcome the official trello board for web2py's roadmap : 
>>> https://trello.com/b/d3aqBbBl
>>>
>>> -- 
>>>  
>>> --- 
>>> 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.
>>>  
>>>  
>>>
>>
>>
>>
>> -- 
>> Joe Simpson
>>
>> Sent From My DROID!! 
>>
>

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Dmitri Husti
Hi,
Is it possible to pass the request vars and call the function 
dynamic_search twice?
redirect(URL("test",vars=request.vars))



Am Mittwoch, 17. Juli 2013 18:46:07 UTC+2 schrieb Massimo Di Pierro:
>
> You can store the results in session then.
>
> session.rows = db(...).select()
>
> Passing to much data in request.vars can be a problem. For example nginx 
> limits the size of the query string.
>
>
>
>
> On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote:
>>
>> HI,
>> you can pass results to the next page;
>> redirect(URL("test",vars=dict(results=results))
>>
>> On the next page you can do 
>> return dict(results=request.vars["results"])
>>
>> Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh:
>>>
>>> Hi,
>>>
>>> I am trying to use "dynamic search form" from 
>>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>>> implementation shows both the form and results on the same page.
>>>
>>> I want to display the search results (using GRID) in a new page and 
>>> wants to use customized forms for edit/view operations associated with GRID.
>>>
>>> As of now, I tried handling it in the view to not to show form contents 
>>> once the form is accessed but some how it is not working on subsequent 
>>> operations.
>>>
>>> So, I am thinking to pass query to a new controller and can hence handle 
>>> the custom forms there. But I am not able to do so.
>>>
>>> So here is what I tried :
>>>
>>> @auth.requires_login()  
>>> def search2():
>>> form,query = dynamic_search(db.customer)
>>> if form.process().accepted:
>>> session.sqlquery = query
>>> redirect(URL('results'))
>>> return dict(form=form)
>>>
>>> @auth.requires_login() 
>>> def results():
>>> query = session.sqlquery
>>> print query
>>> results =  
>>> SQLFORM.grid(query,searchable=False,create=False,csv=False)
>>> results = None
>>> return dict(results=results)
>>>
>>> With this code, first error that is encountered is in "session.sqlquery 
>>> = query" -> Can't pickle objects 
>>>
>>> So I modified it as 
>>>
>>> session.sqlquery = str(query)
>>>
>>> With this error appeared in "query = session.sqlquery" -> str object has 
>>> no attribute _db
>>>
>>> Can some one please suggest what is the right way to achieve this?
>>>
>>> -Sarbjit
>>>
>>>

-- 

--- 
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] Inject HTML in field definition

2013-07-17 Thread Woody
I have a table definition that uses virtual fields with XML:

db_mydb.define_table('my_table',
Field('ROWID', 'id'),
Field('location', 'string'),
Field('description', 'string', required=False),
Field.Virtual('description_formatted', lambda row: 
XML('' + row.description + ''), 
etc

So, using Field.Virtual, I can pass XML with HTML tags to a table. Is there 
a way to do this without having to create a virtual field?  In other words, 
I'd like to be able to add HTML formatting in a normal field definition, 
using XML or helper functions.

-- 

--- 
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] web2py roadmap

2013-07-17 Thread greaneym
Hi,

I get a blank screen also on that url link.

margaret

On Tuesday, July 16, 2013 11:10:32 AM UTC-5, jjs0sbw wrote:
>
> I get a blank screen???
>
>
> On Sun, Jul 14, 2013 at 1:30 PM, Niphlod  >wrote:
>
>> web2py's developers work often "behind the curtain" and users are not 
>> able to see what they're working on. Historically we tracked down 
>> feature-requests and todo-lists on google code, but it's a nightmare to 
>> track them and work with it efficiently.
>>
>> On a nice tip received by a power web2py user, we (developers) decided to 
>> create something more readable to give us (developers AND users) a nice 
>> representation on what's going on.
>>
>> Please welcome the official trello board for web2py's roadmap : 
>> https://trello.com/b/d3aqBbBl
>>
>> -- 
>>  
>> --- 
>> 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.
>>  
>>  
>>
>
>
>
> -- 
> Joe Simpson
>
> Sent From My DROID!! 
>

-- 

--- 
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] Crud.update returning none

2013-07-17 Thread gkuffel22
Hi Everyone,

I am brand new to web2py and I am definitely still learning. I am trying to 
build a simple application that allows me store, edit, and delete projects 
and users. I have made some progress but when I cannot get the method 
crud.update to function as expected. I have pasted my code below when I 
call the method project_edit or user_edit a page pops up displaying "None" 
eventhough there are users and projects stored. Any help would be greatly 
appreciated.

Code located in default.py in controllers:

def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

if you need a simple wiki simple replace the two lines below with:
return auth.wiki()
"""
return locals()

def projects():
projects = db(db.projects).select(orderby=db.projects.description)
return locals()

def users():
project = db.projects(request.args(0)) 
users = db(db.users.project).select(orderby=db.projects.description)
return locals()

def project_create():
form = crud.create(db.projects, next = 'projects')
return locals()

def project_edit():
project = db.projects.request.args(0)
form = crud.update(db.projects, project , next='projects')

def user_create():
db.users.project.default = request.args(0)
form = crud.create(db.users, next = 'users')
return locals()

def user_edit():
user = db.users(request.args(0)) 
form = crud.update(db.users, user, next = 'users')

def user():
"""
exposes:
http:///[app]/default/user/login
http:///[app]/default/user/logout
http:///[app]/default/user/register
http:///[app]/default/user/profile
http:///[app]/default/user/retrieve_password
http:///[app]/default/user/change_password
http:///[app]/default/user/manage_users (requires membership in 
use @auth.requires_login()
@auth.requires_membership('group name')
@auth.requires_permission('read','table name',record_id)
to decorate functions that need access control
"""
return dict(form=auth())

@cache.action()
def download():
"""
allows downloading of uploaded files
http:///[app]/default/download/[filename]
"""
return response.download(request, db)


def call():
"""
exposes services. for example:
http:///[app]/default/call/jsonrpc
decorate with @services.jsonrpc the functions to expose
supports xml, json, xmlrpc, jsonrpc, amfrpc, rss, csv
"""
return service()


@auth.requires_signature()
def data():
"""
http:///[app]/default/data/tables
http:///[app]/default/data/create/[table]
http:///[app]/default/data/read/[table]/[id]
http:///[app]/default/data/update/[table]/[id]
http:///[app]/default/data/delete/[table]/[id]
http:///[app]/default/data/select/[table]
http:///[app]/default/data/search/[table]
but URLs must be signed, i.e. linked with
  A('table',_href=URL('data/tables',user_signature=True))
or with the signed load operator
  
LOAD('default','data.load',args='tables',ajax=True,user_signature=True)
"""
return dict(form=crud())

-- 

--- 
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: Is there an issue with my web2py install? "can't pickle function objects"

2013-07-17 Thread Joe Magaro
Hi Mossimo - Where would I look for this? I haven't done sessions in my 
apps yet, but maybe one of the projects I loaded might have. Also, why 
would an app affect the admin site?
 

On Tuesday, July 16, 2013 10:44:46 PM UTC-4, Joe Magaro wrote:

> Hi, Lately when I'm in the admin section, when I perform an action such as 
> installing a new app, or deleting a view I keep getting the error below. Im 
> not sure what changed to affect this, please help!
>
> raceback (most recent call last):
>   File "/home/www-data/web2py/gluon/main.py", line 606, in wsgibase
> session._try_store_in_cookie_or_file(request, response)
>   File "/home/www-data/web2py/gluon/globals.py", line 757, in 
> _try_store_in_cookie_or_file
> self._try_store_in_file(request, response)
>   File "/home/www-data/web2py/gluon/globals.py", line 763, in 
> _try_store_in_file
> if not response.session_id or self._forget or self._unchanged():
>   File "/home/www-data/web2py/gluon/globals.py", line 719, in _unchanged
> session_pickled = cPickle.dumps(dict(self))
>   File "/usr/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
> raise TypeError, "can't pickle %s objects" % base.__name__
> TypeError: can't pickle function objects
>
> Error snapshot [image: 
> help]
>
> (can't pickle function objects)
>

-- 

--- 
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: better calendar.js?

2013-07-17 Thread Annet
I had a look at the datetime picker, I miss the month and year menus and 
the week of the year. Furthermore I find the 
display of dates in other months distracting, the styling could be a bit 
more calendar like.


Kind regards,

Annet.

-- 

--- 
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] Mobile and Tablets detection

2013-07-17 Thread Marcio Andrey Oliveira
Hi.

I'm wondering whether exists a python project that detect mobiles and 
tables that be as good and as up to date as http://mobiledetect.net/

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: Micro-framework performance vs Web2py?

2013-07-17 Thread greenpoise
Excellent.. Thanks

On Wednesday, July 17, 2013 9:27:28 AM UTC-7, greenpoise wrote:
>
> Total ignorant question here but is there any difference at all between 
> these two in terms of performance?  Any experiences from users out there?
>
>

-- 

--- 
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: is there a way for user to populate a field using a wildcard search for "requires = IS_IN_DB"?

2013-07-17 Thread Derek
also check out these:
http://dev.s-cubism.com/web2py_plugins

On Wednesday, July 17, 2013 10:40:10 AM UTC-7, Derek wrote:
>
> Try the builtin autocomplete widget...
>
> http://web2py.com/book/default/chapter/07#Autocomplete-widget
>
>
> On Wednesday, July 17, 2013 10:30:06 AM UTC-7, Alex Glaros wrote:
>>
>> There will be thousands of records to choose from, so a dropdown 
>> selection list would be inconvenient.
>>
>> By wildcard search, I mean a partial string search, or search by ID or 
>> other field alternatives like in sqlForm, that would replace the dropdown.
>>
>> If not, are there other ways to get around the problem of having so many 
>> choices in the dropdown?
>>
>> thanks,
>>
>> Alex Glaros
>>
>

-- 

--- 
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: is there a way for user to populate a field using a wildcard search for "requires = IS_IN_DB"?

2013-07-17 Thread Derek
Try the builtin autocomplete widget...

http://web2py.com/book/default/chapter/07#Autocomplete-widget


On Wednesday, July 17, 2013 10:30:06 AM UTC-7, Alex Glaros wrote:
>
> There will be thousands of records to choose from, so a dropdown selection 
> list would be inconvenient.
>
> By wildcard search, I mean a partial string search, or search by ID or 
> other field alternatives like in sqlForm, that would replace the dropdown.
>
> If not, are there other ways to get around the problem of having so many 
> choices in the dropdown?
>
> thanks,
>
> Alex Glaros
>

-- 

--- 
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 way for user to populate a field using a wildcard search for "requires = IS_IN_DB"?

2013-07-17 Thread Alex Glaros
There will be thousands of records to choose from, so a dropdown selection 
list would be inconvenient.

By wildcard search, I mean a partial string search, or search by ID or 
other field alternatives like in sqlForm, that would replace the dropdown.

If not, are there other ways to get around the problem of having so many 
choices in the dropdown?

thanks,

Alex Glaros

-- 

--- 
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 make app setup / is it possible to have modelless app?

2013-07-17 Thread dhmorgan
you may want to look at how tiny_website (
https://github.com/espern/tiny_website) handles its setup at first run of 
application

On Tuesday, July 16, 2013 5:34:55 PM UTC-5, Dragan Matic wrote:
>
> What would be the best way to create an app setup? After 
> uploading/installing an app to a server I would like a user to be able to 
> start a setup page where he would choose a database/user/password and a few 
> other configuration parameters. Problem is that for every called page model 
> is executed and it wants to create a db object and create tables. Is it 
> possible to execute a controller without a model and execute a model only 
> after setting up database parameters?
>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Alan Etkin
El miércoles, 17 de julio de 2013 12:14:25 UTC-3, Massimo Di Pierro 
escribió:
>
> I agree. It should  also support the use of variable already passed to the 
> MARKMIN environment. Yet it should not support expressions and python code. 
> All of this may not be easy since we do not want to user eval.


I have opened two issues (one for fixing the unparsed args and the other 
for the enhancements)

http://code.google.com/p/web2py/issues/detail?id=1589
http://code.google.com/p/web2py/issues/detail?id=1590

-- 

--- 
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: Micro-framework performance vs Web2py?

2013-07-17 Thread Massimo Di Pierro
Microframework is often used as a marketing buzzword. For example web2py 
core consists of only the files web2py.py and gluon/*.py. All together they 
have less size then some "micro frameworks".

Speedwise the bottle neck for everybody is DB IO. If you use a database 
than all frameworks perform more or less the same.
If you do not use the database and you do not use a template language, and 
you only serve cached content, than web2py is slower because it does things 
by default that cannot be disabled (parsing of input, session handing, many 
security checks). This total time is negligible for real life apps. In my 
experience, this becomes important only when you want to served cached 
pages without authentication or do async IO.

For Async IO I like Tornado and Gevent.

The only true micro frameworks for me are Bottle and web.py because they 
are small. That is why they are also very fast. The less they do the faster 
they are. I personally like Bottle because it is very well designed and 
consists of one single file. In my experience the fastest of all are 
Tornado and Bottle.

Massimo


On Wednesday, 17 July 2013 11:27:28 UTC-5, greenpoise wrote:
>
> Total ignorant question here but is there any difference at all between 
> these two in terms of performance?  Any experiences from users out there?
>
>

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Massimo Di Pierro
You can store the results in session then.

session.rows = db(...).select()

Passing to much data in request.vars can be a problem. For example nginx 
limits the size of the query string.




On Wednesday, 17 July 2013 10:48:15 UTC-5, Dmitri Husti wrote:
>
> HI,
> you can pass results to the next page;
> redirect(URL("test",vars=dict(results=results))
>
> On the next page you can do 
> return dict(results=request.vars["results"])
>
> Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh:
>>
>> Hi,
>>
>> I am trying to use "dynamic search form" from 
>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>> implementation shows both the form and results on the same page.
>>
>> I want to display the search results (using GRID) in a new page and wants 
>> to use customized forms for edit/view operations associated with GRID.
>>
>> As of now, I tried handling it in the view to not to show form contents 
>> once the form is accessed but some how it is not working on subsequent 
>> operations.
>>
>> So, I am thinking to pass query to a new controller and can hence handle 
>> the custom forms there. But I am not able to do so.
>>
>> So here is what I tried :
>>
>> @auth.requires_login()  
>> def search2():
>> form,query = dynamic_search(db.customer)
>> if form.process().accepted:
>> session.sqlquery = query
>> redirect(URL('results'))
>> return dict(form=form)
>>
>> @auth.requires_login() 
>> def results():
>> query = session.sqlquery
>> print query
>> results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
>> results = None
>> return dict(results=results)
>>
>> With this code, first error that is encountered is in "session.sqlquery = 
>> query" -> Can't pickle objects 
>>
>> So I modified it as 
>>
>> session.sqlquery = str(query)
>>
>> With this error appeared in "query = session.sqlquery" -> str object has 
>> no attribute _db
>>
>> Can some one please suggest what is the right way to achieve this?
>>
>> -Sarbjit
>>
>>

-- 

--- 
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] Function for downloading files

2013-07-17 Thread lesssugar
There's default/download function, usually used like this on files that 
were uploaded:

Download

In this case, I do not want to keep the full download path in my  tag. 
Instead, when the link is clicked, I would like to redirect to another 
function, which will proceed with the download based on request.args(0).

I tried to do the following but nothing happens after clicking the link:

link

Download

controller/download_file

def download_file():
file = db(db.files.user_id == int(request.args(0))).select()
for f in file:
name = f.name
 return response.download(name,db)




-- 

--- 
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: Submit several records to a table from one form

2013-07-17 Thread Andrey Oleynik
Massimo, thank you for reply.

Initially I thought about adding input fields to the form like 
here and 
then save their values to table authors in the loop right after saving the 
rest part of the form to table book.

среда, 17 июля 2013 г., 16:22:10 UTC+4 пользователь Massimo Di Pierro 
написал:
>
> If you do not have many authors (if they fix in a dropdown) you can do
> db.define_table('book',...,Field('authors','list:reference author'))
> and use the plugin_mupliselect that ships with admin.
>
> Otherwise you cannot think of a single way to do it with a single form. 
>
> I would have two pages
> 1) one contains a search for authors and the option to add options to a 
> cart via ajax (like a shopping cart)
> 2) one creates book with a 'list:reference author' that picks up values 
> from the cart and clears the cart.
> then you can embed 1) into 2) via LOAD(...)
>
> It can be done in few lines of code. Something like:
>
> session.cart = session.cart or []
> db.define_table('author',Field('name'))
> db,define_table('book',Field('title'),Field('authors','list:reference 
> author',readable=False,writable=False)
>
> def cart():
>  grid = SQLFORM.grid(db.author,links=[lambda row: 
> A('add',callback=URL('add',args=row.id))])
>  return grid
>
> def add():
>  if request.env.request_method == 'POST':
>  id = request.args(0,cast=int)
>  if not id in session.cart: session.cart.append(id)
>  return 'added'
>
> def create_book():
>  db.book.authors.default=session.cart
>  form = SQLFORM(db.book)
>  cart = LOAD(request.controller,'cart')
>  return dict(form=form,cart=cart)
>
>
>
> On Wednesday, 17 July 2013 01:14:27 UTC-5, Andrey Oleynik wrote:
>>
>> Hi!
>>
>> I want to submit more than one record to a table from the form.
>>
>> e.g. i have the following tables in the db:
>>
>> db.define_table('book',
>>
>> Field ('title')*)
>> **
>> *db.define_table('author',
>>
>> Field ('name')
>> Field ('book', 
>> 'reference book'))
>>
>>
>> and function:
>>
>> def submit():
>> form=SQLFORM 
>> .factory(db.book,db.author)
>> if form.process().accepted:
>> id = db.book.insert(**db.book._filter_fields(form.vars))
>> form.vars.book=id
>> id = db.author.insert(**db.author._filter_fields(form.vars))
>> response 
>> .flash='Thanks for 
>> filling the form'
>>
>> return dict(form=form)
>>
>> As result of submitting this form I gets by one record in each tables. 
>> How could I add more than one author of the book from the form without 
>> adding the authors in advance?
>>
>> 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] Micro-framework performance vs Web2py?

2013-07-17 Thread greenpoise
Total ignorant question here but is there any difference at all between 
these two in terms of performance?  Any experiences from users out there?

-- 

--- 
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: AWS Elastic Beanstalk installation Recipe

2013-07-17 Thread Aladdin Teng
Hi!

Is there an update on this demo?
I am looking into AWS deployment too.

Thanks.

On Saturday, October 13, 2012 9:52:03 AM UTC+8, Massimo Di Pierro wrote:
>
> I will try a demo asap but I do not have an account so it will take a 
> tille time. In principle everything in eb is not django specific and should 
> work with web2py almost out of them box.
>
> On Tuesday, 9 October 2012 11:42:35 UTC-5, CST International Mike wrote:
>>
>> Hi 
>>
>> I trying to find an AWS Elastic Beanstalk Web2py installation recipe.
>>
>> Amazon have a Django version 
>> http://docs.amazonwebservices.com/elasticbeanstalk/latest/dg/create_deploy_Python_django.html
>>
>> My Linux\web2py skill are a little weak and rusty. ( over a year now)
>>
>> Regards Michael
>>
>>
>>
>>
>>
>>

-- 

--- 
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: Minify (compress) response HTML

2013-07-17 Thread Kernc
Can you elaborate what JavaScript code is that?

I had problems with e.g. recaptcha module, which starts the script with:

> 
>
and when minimized, this became:

> 
>
which didn't work, so I preserved 

[web2py] Re: web2py resources

2013-07-17 Thread Massimo Di Pierro
I believe Bruno Rocha does.

On Tuesday, 16 July 2013 16:09:54 UTC-5, Marian Siwiak wrote:
>
> Does anyone know who runs web2pyslices? Something has gone wrong and it 
> issues tickets... Maybe it's worth to mention it to the admin. 
>
> On Sunday, 5 May 2013 01:03:06 UTC+2, Anthony wrote:
>>
>> You can post recipes and articles here: http://www.web2pyslices.com. 
>> There was at least one wiki in the past, but it became neglected and 
>> ultimately abandoned.
>>
>> Anthony
>>
>> On Saturday, May 4, 2013 6:38:01 PM UTC-4, Fabiano wrote:
>>>
>>> This thread has a very useful collection references and resources.
>>>
>>> I've seen a lot of great stuff on this list but over time it gets harder 
>>> to dig the mailing due the high amount of messages. I understand somethings 
>>> don't fit on the main website and putting things in there requires some 
>>> effort and overhead (review, maintenance, access, etc.).
>>>
>>> Have you guys considered using a wiki for this kind of stuff? I think 
>>> this kind of information could easily be placed in there and maintained by 
>>> the community.
>>>
>>> The Google Code project hosting where the Issues tracker is already has 
>>> a wiki which could be used, so there is no need to setup one.
>>>
>>> What you think of this suggestion?
>>>
>>> Fabiano.
>>>
>>> On Monday, April 30, 2012 4:49:41 PM UTC-3, Anthony wrote:

 Most web2py resources can be found on web2py.com, but here are some 
 Google Groups topics identifying additional resources:

 web2py help & 
 resources
 Plugins
 Signature 
 apps
 Featured web2py 
 apps
 web2py 
 hosting

>>>

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Dmitri Husti
HI,
you can pass results to the next page;
redirect(URL("test",vars=dict(results=results))

On the next page you can do 
return dict(results=request.vars["results"])

Am Mittwoch, 17. Juli 2013 12:37:24 UTC+2 schrieb Sarbjit singh:
>
> Hi,
>
> I am trying to use "dynamic search form" from 
> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
> implementation shows both the form and results on the same page.
>
> I want to display the search results (using GRID) in a new page and wants 
> to use customized forms for edit/view operations associated with GRID.
>
> As of now, I tried handling it in the view to not to show form contents 
> once the form is accessed but some how it is not working on subsequent 
> operations.
>
> So, I am thinking to pass query to a new controller and can hence handle 
> the custom forms there. But I am not able to do so.
>
> So here is what I tried :
>
> @auth.requires_login()  
> def search2():
> form,query = dynamic_search(db.customer)
> if form.process().accepted:
> session.sqlquery = query
> redirect(URL('results'))
> return dict(form=form)
>
> @auth.requires_login() 
> def results():
> query = session.sqlquery
> print query
> results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
> results = None
> return dict(results=results)
>
> With this code, first error that is encountered is in "session.sqlquery = 
> query" -> Can't pickle objects 
>
> So I modified it as 
>
> session.sqlquery = str(query)
>
> With this error appeared in "query = session.sqlquery" -> str object has 
> no attribute _db
>
> Can some one please suggest what is the right way to achieve this?
>
> -Sarbjit
>
>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Alan Etkin

>
> I am thinking that for security reasons it may be better to leave the book 
> un-changed and make it work as described by doing the parsing properly and 
> safely.
>

Agree. Nevermind my patch then.

BTW: perhaps the new implementation could support also keyword arguments 
and basic types (ints, string, float)

-- 

--- 
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: better calendar.js?

2013-07-17 Thread Niphlod
and all the customizations, such as the time, date and datetime accepted 
formats.

On Wednesday, July 17, 2013 11:15:57 AM UTC+2, Massimo Di Pierro wrote:
>
> Does anybody wants to attempt a replacement of the current calendar.js? We 
> will have to check it works without bootstrap css.
>
> On Tuesday, 16 July 2013 16:01:41 UTC-5, LightDot wrote:
>>
>> Looks nice. Probably worth looking into this...
>>
>> Regards,
>> Ales
>>
>> On Thursday, July 11, 2013 9:26:15 PM UTC+2, Jim S wrote:
>>>
>>> I agree it is nicer and easier to use than the current date/time popup. 
>>>  Yes, it does support time.  Is there a way it could be an optional feature 
>>> you could turn on if you're using bootstrap?
>>>
>>> -Jim
>>>
>>> On Thursday, July 11, 2013 1:03:09 PM UTC-5, Massimo Di Pierro wrote:

 But we do not want the popup to break when people replace bootstrap 
 with a different style.

 On Thursday, 11 July 2013 12:19:33 UTC-5, VP wrote:
>
> Massimo:
>
> I just came across it, so I don't know 100% for sure.  But I think it 
> only depends on bootstrap which is included in web2py.
>
>

-- 

--- 
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: Have to delete @auth.requires_signature() fom default.py or app fails?

2013-07-17 Thread Niphlod
the default data() function exposes all tables. That's why it's by default 
protected. When you stripped off your model, you deleted the part that 
istantiate all the authentication "feature" of web2py. 
By default every app has that "feature" (that is a module) available as 
"auth" . That's why the decorator call (auth.requires_*) goes into error: 
in your app "auth" doesn't exist.

Just delete the def data(): function and live happy for the time being ^_^

On Wednesday, July 17, 2013 10:35:37 AM UTC+2, Jeremy Hankenson wrote:
>
> Hello all, 
> Just learning how to program for the web and creating a simple blog to 
> learn off of. 
>
> I created app called blog and a new controller called blog.py and a model 
> called db.py. My blog controller looks like this:
> def index():
> return dict()
>
> def create_post():
> return dict()
>
> def remove_post():
> return dict()
>
> def edit_post():
> return dict()
>
>
>
> My model is incredibly simple as can be. 
> # -*- coding: utf-8 -*-
>
> db = DAL("sqlite://blog.sqlite")
>
> db.define_table('post',
> Field('title', unique=True),
> Field('author'),
> Field('body', 'text'))
>
> When I run my website blog, I get a error as such: 
>  name 'auth' is not defined
> but if I remove "@auth.requires_signature()" above the action "data" 
> inside the "default.py" file. My application will run just fine. 
>
> Why is this? What is the point of @auth.requires_signature() and why do I 
> only get this error after creating a model?
>
> Thank you very much, and thanks for the great framework!
>

-- 

--- 
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: web2py resources

2013-07-17 Thread Alan Etkin

>
> I believe Bruno Rocha does.
>
> On Tuesday, 16 July 2013 16:09:54 UTC-5, Marian Siwiak wrote:
>>
>> Does anyone know who runs web2pyslices? Something has gone wrong and it 
>> issues tickets... Maybe it's worth to mention it to the admin. 
>
>
Up and running now. Please check it. We have been adding some features for 
preventing spam and also the new package database (web2py reusable 
projects). I will post the changes in a new thread.

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Massimo Di Pierro
I agree. It should  also support the use of variable already passed to the 
MARKMIN environment. Yet it should not support expressions and python code. 
All of this may not be easy since we do not want to user eval.


On Wednesday, 17 July 2013 10:05:18 UTC-5, Alan Etkin wrote:
>
> I am thinking that for security reasons it may be better to leave the book 
>> un-changed and make it work as described by doing the parsing properly and 
>> safely.
>>
>
> Agree. Nevermind my patch then.
>
> BTW: perhaps the new implementation could support also keyword arguments 
> and basic types (ints, string, float)
>
>

-- 

--- 
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: Problem with @request.restful()

2013-07-17 Thread Massimo Di Pierro
I do not know what @Other.decorator() does.
My guess is
1) @Other.decorator without ()
2) swap the order of the recorators.

On Wednesday, 17 July 2013 07:30:26 UTC-5, Eduardo Cruz wrote:
>
> I have a function like this 
>
> @request.restful()
> def api():
> def GET(*args,**vars):
> return dict()
> def POST(*args,**vars):
> return dict()
> def PUT(*args,**vars):
> return dict()
> def DELETE(*args,**vars):
> return dict()
> return locals()
>
> then I try to use another decorator,
> so it was like this
>
> @Other.decorator()
> @request.restful()
> def api():
> def GET(*args,**vars):
> return dict()
> def POST(*args,**vars):
> return dict()
> def PUT(*args,**vars):
> return dict()
> def DELETE(*args,**vars):
> return dict()
> return locals()
>
>
>
> And It was given me an error 
> TypeError: _decorated() takes exactly 1 argument (0 
> given)
>
> So I just remove the other decorator but it keeps giving me that error, 
> What did I do wrong?
>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Massimo Di Pierro
I am thinking that for security reasons it may be better to leave the book 
un-changed and make it work as described by doing the parsing properly and 
safely.

On Wednesday, 17 July 2013 08:24:58 UTC-5, dhmorgan wrote:
>
> Thank you both for helping me out here.
>
> Changing the lambda, as indicated in the pending book correction, works.
>
>
> in controller:
>
> def index(): 
> return auth.wiki(env=dict(join=lambda a:"-".join(a.split(","
>
>
> in wiki page body:
>
> @{join:'this',that','the other'}
>
> @{join:how,you,doin'} 
>
> result:
>
> 'this'-'that'-'the other'
>
> how-you-doin'
>
>
> Danny
>
>
>
> On Wednesday, July 17, 2013 7:16:03 AM UTC-5, Alan Etkin wrote:
>>
>> I have a possible correction here
>>
>> https://github.com/mdipierro/web2py-book/pull/86
>>
>

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Massimo Di Pierro
What I man you need to be able to build a string (or object) that 
represents the query and store this object in the query. Then retrieve the 
object and rebuild the query.


On Wednesday, 17 July 2013 07:15:32 UTC-5, Sarbjit singh wrote:
>
> I am  not aware of the word "serialize", Is there any possibility to 
> achieve it?
>
>
>
> On Wednesday, July 17, 2013 5:36:33 PM UTC+5:30, Massimo Di Pierro wrote:
>>
>> A query object cannot be put into a session unless you somehow serialize 
>> (but not with automated pickle/marshall/etc).
>>
>> On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote:
>>>
>>> Hi,
>>>
>>> I am trying to use "dynamic search form" from 
>>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>>> implementation shows both the form and results on the same page.
>>>
>>> I want to display the search results (using GRID) in a new page and 
>>> wants to use customized forms for edit/view operations associated with GRID.
>>>
>>> As of now, I tried handling it in the view to not to show form contents 
>>> once the form is accessed but some how it is not working on subsequent 
>>> operations.
>>>
>>> So, I am thinking to pass query to a new controller and can hence handle 
>>> the custom forms there. But I am not able to do so.
>>>
>>> So here is what I tried :
>>>
>>> @auth.requires_login()  
>>> def search2():
>>> form,query = dynamic_search(db.customer)
>>> if form.process().accepted:
>>> session.sqlquery = query
>>> redirect(URL('results'))
>>> return dict(form=form)
>>>
>>> @auth.requires_login() 
>>> def results():
>>> query = session.sqlquery
>>> print query
>>> results =  
>>> SQLFORM.grid(query,searchable=False,create=False,csv=False)
>>> results = None
>>> return dict(results=results)
>>>
>>> With this code, first error that is encountered is in "session.sqlquery 
>>> = query" -> Can't pickle objects 
>>>
>>> So I modified it as 
>>>
>>> session.sqlquery = str(query)
>>>
>>> With this error appeared in "query = session.sqlquery" -> str object has 
>>> no attribute _db
>>>
>>> Can some one please suggest what is the right way to achieve this?
>>>
>>> -Sarbjit
>>>
>>>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread dhmorgan
Thank you both for helping me out here.

Changing the lambda, as indicated in the pending book correction, works.


in controller:

def index(): 
return auth.wiki(env=dict(join=lambda a:"-".join(a.split(","


in wiki page body:

@{join:'this',that','the other'}

@{join:how,you,doin'} 

result:

'this'-'that'-'the other'

how-you-doin'


Danny



On Wednesday, July 17, 2013 7:16:03 AM UTC-5, Alan Etkin wrote:
>
> I have a possible correction here
>
> https://github.com/mdipierro/web2py-book/pull/86
>

-- 

--- 
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: customized Web2py registration

2013-07-17 Thread Alan Etkin
> In case someone is interested in this feature

I have a working implementation now, but needs revision

(check the issue page)

-- 

--- 
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] Problem with @request.restful()

2013-07-17 Thread Eduardo Cruz
I have a function like this 

@request.restful()
def api():
def GET(*args,**vars):
return dict()
def POST(*args,**vars):
return dict()
def PUT(*args,**vars):
return dict()
def DELETE(*args,**vars):
return dict()
return locals()

then I try to use another decorator,
so it was like this

@Other.decorator()
@request.restful()
def api():
def GET(*args,**vars):
return dict()
def POST(*args,**vars):
return dict()
def PUT(*args,**vars):
return dict()
def DELETE(*args,**vars):
return dict()
return locals()



And It was given me an error 
TypeError: _decorated() takes exactly 1 argument (0 
given)

So I just remove the other decorator but it keeps giving me that error, 
What did I do wrong?

-- 

--- 
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: Submit several records to a table from one form

2013-07-17 Thread Massimo Di Pierro
If you do not have many authors (if they fix in a dropdown) you can do
db.define_table('book',...,Field('authors','list:reference author'))
and use the plugin_mupliselect that ships with admin.

Otherwise you cannot think of a single way to do it with a single form. 

I would have two pages
1) one contains a search for authors and the option to add options to a 
cart via ajax (like a shopping cart)
2) one creates book with a 'list:reference author' that picks up values 
from the cart and clears the cart.
then you can embed 1) into 2) via LOAD(...)

It can be done in few lines of code. Something like:

session.cart = session.cart or []
db.define_table('author',Field('name'))
db,define_table('book',Field('title'),Field('authors','list:reference 
author',readable=False,writable=False)

def cart():
 grid = SQLFORM.grid(db.author,links=[lambda row: 
A('add',callback=URL('add',args=row.id))])
 return grid

def add():
 if request.env.request_method == 'POST':
 id = request.args(0,cast=int)
 if not id in session.cart: session.cart.append(id)
 return 'added'

def create_book():
 db.book.authors.default=session.cart
 form = SQLFORM(db.book)
 cart = LOAD(request.controller,'cart')
 return dict(form=form,cart=cart)



On Wednesday, 17 July 2013 01:14:27 UTC-5, Andrey Oleynik wrote:
>
> Hi!
>
> I want to submit more than one record to a table from the form.
>
> e.g. i have the following tables in the db:
>
> db.define_table('book',
>
> Field ('title')*)
> **
> *db.define_table('author',
>
> Field ('name')
> Field ('book', 
> 'reference book'))
>
>
> and function:
>
> def submit():
> form=SQLFORM 
> .factory(db.book,db.author)
> if form.process().accepted:
> id = db.book.insert(**db.book._filter_fields(form.vars))
> form.vars.book=id
> id = db.author.insert(**db.author._filter_fields(form.vars))
> response 
> .flash='Thanks for 
> filling the form'
>
> return dict(form=form)
>
> As result of submitting this form I gets by one record in each tables. 
> How could I add more than one author of the book from the form without 
> adding the authors in advance?
>
> 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: How do I pass a query object to a different controller?

2013-07-17 Thread Sarbjit singh
I am  not aware of the word "serialize", Is there any possibility to 
achieve it?



On Wednesday, July 17, 2013 5:36:33 PM UTC+5:30, Massimo Di Pierro wrote:
>
> A query object cannot be put into a session unless you somehow serialize 
> (but not with automated pickle/marshall/etc).
>
> On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote:
>>
>> Hi,
>>
>> I am trying to use "dynamic search form" from 
>> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
>> implementation shows both the form and results on the same page.
>>
>> I want to display the search results (using GRID) in a new page and wants 
>> to use customized forms for edit/view operations associated with GRID.
>>
>> As of now, I tried handling it in the view to not to show form contents 
>> once the form is accessed but some how it is not working on subsequent 
>> operations.
>>
>> So, I am thinking to pass query to a new controller and can hence handle 
>> the custom forms there. But I am not able to do so.
>>
>> So here is what I tried :
>>
>> @auth.requires_login()  
>> def search2():
>> form,query = dynamic_search(db.customer)
>> if form.process().accepted:
>> session.sqlquery = query
>> redirect(URL('results'))
>> return dict(form=form)
>>
>> @auth.requires_login() 
>> def results():
>> query = session.sqlquery
>> print query
>> results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
>> results = None
>> return dict(results=results)
>>
>> With this code, first error that is encountered is in "session.sqlquery = 
>> query" -> Can't pickle objects 
>>
>> So I modified it as 
>>
>> session.sqlquery = str(query)
>>
>> With this error appeared in "query = session.sqlquery" -> str object has 
>> no attribute _db
>>
>> Can some one please suggest what is the right way to achieve this?
>>
>> -Sarbjit
>>
>>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Alan Etkin
I have a possible correction here

https://github.com/mdipierro/web2py-book/pull/86

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Massimo Di Pierro
Tis gives us two options: fix the docs or change the code. I may be easier 
to fix the code. How about we do:

@{join:1,2,3} we first parse as c = {'a':'join','b':'1,2,3') then we do 
args = ast.literal_eval('(%s)' % c['b'] and then we call env[c['a']](*args)?

On Wednesday, 17 July 2013 06:47:07 UTC-5, Alan Etkin wrote:
>
> The correct syntax as far as the wiki is concerned is
>>
>> @{join:a,b,c}
>>
>> The problem is that MARKMIN identifies the call to "join" and the args 
>> "a,b,c" but it does not parse the args. You will have to do that:
>>
>> def myjoin(vars):
>>  items = vars.split(',')
>>  if len(items)==3: return '-'.join(items)
>>  return 'Error!'
>>
>> def index():
>> return auth.wiki(env=dict(join=myjoin)
>>
>
> Then the book example needs to be fixed because the arguments are not 
> parsed by the custom join function.
>
> Also, it is confusing the use of the extra word in "... This calls the 
> join function passed as extra with parameters ..." since there's an extra 
> wiki argument used for additional markmin render functions (to process 
> custom blocks), but that feature is not related to env.
>
>

-- 

--- 
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 do I pass a query object to a different controller?

2013-07-17 Thread Massimo Di Pierro
A query object cannot be put into a session unless you somehow serialize 
(but not with automated pickle/marshall/etc).

On Wednesday, 17 July 2013 05:37:24 UTC-5, Sarbjit singh wrote:
>
> Hi,
>
> I am trying to use "dynamic search form" from 
> http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
> implementation shows both the form and results on the same page.
>
> I want to display the search results (using GRID) in a new page and wants 
> to use customized forms for edit/view operations associated with GRID.
>
> As of now, I tried handling it in the view to not to show form contents 
> once the form is accessed but some how it is not working on subsequent 
> operations.
>
> So, I am thinking to pass query to a new controller and can hence handle 
> the custom forms there. But I am not able to do so.
>
> So here is what I tried :
>
> @auth.requires_login()  
> def search2():
> form,query = dynamic_search(db.customer)
> if form.process().accepted:
> session.sqlquery = query
> redirect(URL('results'))
> return dict(form=form)
>
> @auth.requires_login() 
> def results():
> query = session.sqlquery
> print query
> results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
> results = None
> return dict(results=results)
>
> With this code, first error that is encountered is in "session.sqlquery = 
> query" -> Can't pickle objects 
>
> So I modified it as 
>
> session.sqlquery = str(query)
>
> With this error appeared in "query = session.sqlquery" -> str object has 
> no attribute _db
>
> Can some one please suggest what is the right way to achieve this?
>
> -Sarbjit
>
>

-- 

--- 
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] Redirect in sqlform fails

2013-07-17 Thread Koen Vanhees
Thanks for your reply.

1. I read about form processing.  I thought the .process().accepted call 
would only be caught when "Submit" been pressed?  
2. This is not an insert form, but a view form with update functionalities. 
 It displays the record with the given ID (which is passed through the ID 
call).

Cheers...

Op woensdag 17 juli 2013 13:47:34 UTC+2 schreef viniciusban het volgende:
>
> On Wed, Jul 17, 2013 at 6:02 AM, Koen Vanhees 
> > 
> wrote: 
> > 
> > That redirection works even before the page loads. 
> > What am I doing wrong? 
>
> 2 things: 
>
> 1) the else redirect to "third" because your form wans't processed 
> yet. Check manual and make some experiments to understand form 
> processing flow. 
>
> 2) About your request.vars.id, show us your view. If this is an insert 
> form, you don't have an id yet. Again, check manual about SQLFORM 
> processing flow. 
>

-- 

--- 
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] Submit several records to a table from one form

2013-07-17 Thread Vinicius Assef
Web2py doesn't have this feature natively, yet.

I'm working on some workaround, but it's not finished.

On Wed, Jul 17, 2013 at 3:14 AM, Andrey Oleynik  wrote:
> Hi!
>
> I want to submit more than one record to a table from the form.
>
> e.g. i have the following tables in the db:
>
> db.define_table('book',
>
> Field('title'))
>
> db.define_table('author',
>
> Field('name')
> Field('book', 'reference book'))
>
>
> and function:
>
> def submit():
> form=SQLFORM.factory(db.book,db.author)
> if form.process().accepted:
> id = db.book.insert(**db.book._filter_fields(form.vars))
> form.vars.book=id
> id = db.author.insert(**db.author._filter_fields(form.vars))
> response.flash='Thanks for filling the form'
>
> return dict(form=form)
>
> As result of submitting this form I gets by one record in each tables.
> How could I add more than one author of the book from the form without
> adding the authors in advance?
>
> Thanks
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 

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




Re: [web2py] Redirect in sqlform fails

2013-07-17 Thread Vinicius Assef
On Wed, Jul 17, 2013 at 6:02 AM, Koen Vanhees  wrote:
>
> That redirection works even before the page loads.
> What am I doing wrong?

2 things:

1) the else redirect to "third" because your form wans't processed
yet. Check manual and make some experiments to understand form
processing flow.

2) About your request.vars.id, show us your view. If this is an insert
form, you don't have an id yet. Again, check manual about SQLFORM
processing flow.

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Alan Etkin

>
> The correct syntax as far as the wiki is concerned is
>
> @{join:a,b,c}
>
> The problem is that MARKMIN identifies the call to "join" and the args 
> "a,b,c" but it does not parse the args. You will have to do that:
>
> def myjoin(vars):
>  items = vars.split(',')
>  if len(items)==3: return '-'.join(items)
>  return 'Error!'
>
> def index():
> return auth.wiki(env=dict(join=myjoin)
>

Then the book example needs to be fixed because the arguments are not 
parsed by the custom join function.

Also, it is confusing the use of the extra word in "... This calls the join 
function passed as extra with parameters ..." since there's an extra wiki 
argument used for additional markmin render functions (to process custom 
blocks), but that feature is not related to env.

-- 

--- 
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] Relative links inside builtin wiki pages

2013-07-17 Thread peibol
Hi there, simple question... I'd like to embed links inside the wiki pages 
to some views of my application. Is it possible to use some kind of helper, 
or to embed python expressions in {{}} in order to avoid writing absolute 
urls (which are different in localhost development and maybe dependent of 
deployment)
Thanks
Pablo

-- 

--- 
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: python vs php reading sqlserver data

2013-07-17 Thread António Ramos
I was thinking that the driver could be the issue.

The code is this one but dont expect you to read it.
Just in case you want to read this code...
The data i query is distributed among some tables. The problem is that the
records in the table RESULTS are not just a line record, but many records
that together compose a record

Example
instead of having this record

ID Field1 Field2 Field3 Field3 y have
1 aaabbb cccddd

ID FieldName, value
1field1  aaa
1field2  bbb
1   field3   ccc



# -*- coding: latin-1 -*-
##calculo da média de D90
## for x in docs:
## temp=float(x['DTG_SECA__D90']) if x['DTG_SECA__D90']!="" else 0
## list.append(temp)
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import datetime as dt
import win32com.client
import datetime
import sys
import pickle
conn = win32com.client.Dispatch(r'ADODB.Connection')
rs = win32com.client.Dispatch('ADODB.Recordset')
docs=[]
doc={}
def substitui(valor):
a=valor
return a.replace('
','').replace('-','_').replace('*','x').replace('(','').replace(')','').replace('>','')

def
Output(Analises,Unidades,templateKey,productKey,secagemKey,startDate,endDate,Coluna,sortedList):

samples={}
if secagemKey!='*':
secKey=" and SAMPLE.SAMPLING_POINT LIKE '"+secagemKey+"'"
else:
secKey=''
DSN="Provider=sqloledb;Data Source=192.168.1.14,1433;Initial
Catalog='limslab';User Id='xxx';Password='xxx';"
conn.Open(DSN)
rs_name="SELECT  distinct
SAMPLE.SAMPLE_NUMBER,SAMPLE.TEMPLATE,SAMPLE.ID_PARTIDA,SAMPLE.X_LOTE,SAMPLE.X_PALETE,SAMPLE.STATUS,SAMPLE.SAMPLING_POINT,SAMPLE.PRODUCT,SAMPLE.SAMPLED_DATE,SAMPLE.X_HORA,SAMPLE.X_SILO,SAMPLE.X_PILOTO,SAMPLE.X_RECEITA,SAMPLE.X_OBSERV,SAMPLE.CUSTOMER
FROM SAMPLE where "+templateKey + secKey + " and SAMPLE.SAMPLED_DATE >=
'"+startDate+"' AND SAMPLE.SAMPLED_DATE <= '"+endDate+"' and SAMPLE.PRODUCT
like '"+productKey+"'  and SAMPLE.STATUS<>'X' order by
SAMPLE.SAMPLED_DATE,SAMPLE.X_HORA";
statusKey={'I':'Incompleta','C':'Completa','U':'Não
recebida','X':'Cancelada','P':'Em progresso','A':'Autorizada'}
rs.Open( rs_name , conn)
cont=3
while 1:
if rs.EOF:
   break
else:
sample={}
print checkNone(rs.Fields(0).Value)
sample_number=checkNone(rs.Fields(0).Value)
sample['Template']=checkNone(rs.Fields(1).Value)
sample['ID_PARTIDA']=checkNone(rs.Fields(2).Value)
sample['X_LOTE']=checkNone(rs.Fields(3).Value)
sample['X_PALETE']=checkNone(rs.Fields(4).Value)
sample['Status']=statusKey[rs.Fields(5).Value]
sample['Sampling Point']=checkNone(rs.Fields(6).Value)
sample['Product']=checkNone(rs.Fields(7).Value)
tempdate=str(rs.Fields(8).Value)[:8]
sample['Sampled
Date']="20"+tempdate[6:8]+"-"+tempdate[3:5]+"-"+tempdate[:2]
sample['Hora']=str(rs.Fields(9).Value)
sample['Silo']=checkNone(rs.Fields(10).Value)
sample['X_PILOTO']=checkNone(rs.Fields(11).Value)
sample['X_RECEITA']=checkNone(rs.Fields(12).Value)
sample['X_OBSERV']=checkNone(rs.Fields(13).Value)
sample['CUSTOMER']=checkNone(rs.Fields(14).Value)
samples[sample_number]=sample
rs.MoveNext()
conn.Close()
samplesSorted=samples.keys()
samplesSorted.sort()
for x in samplesSorted:

doc={}
hasrecord=0
Analysis=Analises
conn.Open(DSN)
rs_name="SELECT TEST.ANALYSIS, RESULT.NAME,RESULT.FORMATTED_ENTRY,
RESULT.IN_SPEC FROM SAMPLE,RESULT,TEST WHERE SAMPLE.SAMPLE_NUMBER =
TEST.SAMPLE_NUMBER AND TEST.TEST_NUMBER = RESULT.TEST_NUMBER and
RESULT.SAMPLE_NUMBER="+str(x) +" and RESULT.STATUS<>'X'"
rs.Open( rs_name , conn)
for xx in Analysis:
for yy in Analysis[xx]['subcolunas']:
Analysis[xx]['subcolunas'][yy]=''
while 1:
if rs.EOF:
   break
else:
hasrecord=1
analise=checkNone(rs.Fields(0).Value)
if analise in Analises:
if Coluna in Analises[analise]['imprime']:

#Analysis['LOTE']['subcolunas']['LOTE']=getLote(str(x))[0]
Analysis['Sample N']['subcolunas']['Sample N']=x


Analysis['ID_PARTIDA']['subcolunas']['ID_PARTIDA']=samples[x]['ID_PARTIDA']

Analysis['X_LOTE']['subcolunas']['X_LOTE']=samples[x]['X_LOTE']

Analysis['X_PALETE']['subcolunas']['X_PALETE']=samples[x]['X_PALETE']

Analysis['Status']['subcolunas']['Status']=samples[x]['Status']
Analysis['Sampling Point']['subcolunas']['Sampling
Point']=samples[x]['Sampling Point']

Analysis['Product']['subcolunas']['Product']=samples[x]['Product']
Analysis['Sampled Date']['subcolunas']['Sampled
Date']=samples[x]['Sampled Date']

Analysis['Hora']['subcolunas']['Hora']=samples[x]['Hora']

Analysis['Silo']['s

[web2py] Bootstrap button group in stead of radio widget.

2013-07-17 Thread Johann Spies
I want to replace the use of the SQLFORM.widgets.radio.widget with a
button-group from bootstrap.

I have never created a custom widget before.

So my question is twofold:

1. How can I use the button group created in the view inside a custom form
in such a way that the result of the button clicked will be end up in the
form-vars.

or

2. Are there good guidelines on how to create a widget with this
functionality?  Reading the source code in gluon/sqlhtml.py and the
documentation in the book left me uncertain on how to approach this.



Regards
Johann
-- 
Because experiencing your loyal love is better than life itself,
my lips will praise you.  (Psalm 63:3)

-- 

--- 
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] How do I pass a query object to a different controller?

2013-07-17 Thread Sarbjit singh
Hi,

I am trying to use "dynamic search form" from 
http://www.web2pyslices.com/slice/show/1403/dynamic-search. Current 
implementation shows both the form and results on the same page.

I want to display the search results (using GRID) in a new page and wants 
to use customized forms for edit/view operations associated with GRID.

As of now, I tried handling it in the view to not to show form contents 
once the form is accessed but some how it is not working on subsequent 
operations.

So, I am thinking to pass query to a new controller and can hence handle 
the custom forms there. But I am not able to do so.

So here is what I tried :

@auth.requires_login()  
def search2():
form,query = dynamic_search(db.customer)
if form.process().accepted:
session.sqlquery = query
redirect(URL('results'))
return dict(form=form)

@auth.requires_login() 
def results():
query = session.sqlquery
print query
results =  SQLFORM.grid(query,searchable=False,create=False,csv=False)
results = None
return dict(results=results)

With this code, first error that is encountered is in "session.sqlquery = 
query" -> Can't pickle objects 

So I modified it as 

session.sqlquery = str(query)

With this error appeared in "query = session.sqlquery" -> str object has no 
attribute _db

Can some one please suggest what is the right way to achieve this?

-Sarbjit

-- 

--- 
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: new matplotlib tcl problem

2013-07-17 Thread Marian Siwiak
Solved.
Explanation below is for future reference, if someone will experience
similar problem (as Massimo pointed it in a very gentle way, maybe not that
obvious to an external reader, and this solution is applicable I guess to a
very wide range of problems).
*Solution: It is always worth updating web2py to a newest version. *
I was a bit afraid it may screw something with my app, but I was S
wrong!
Problem existed in version 1.99 and magically (yeach, sure!) disappeared in
2.5.1.
Thanks,
Marian
TAG: library problem, compatibility issues, environment variables, external
library, matplotlib


On Wed, Jul 17, 2013 at 11:06 AM, Massimo Di Pierro <
massimo.dipie...@gmail.com> wrote:

> Based on this: github.com/web2py/web2py
> you are right
>
>
> On Tuesday, 16 July 2013 14:21:51 UTC-5, Marian Siwiak wrote:
>>
>> Hi,
>>
>> I try to run a module starting with:
>>
>> def mymodule(*variables*):
>> import matplotlib
>> matplotlib.use('Agg')
>> from pymol import *
>>
>> When I call it, I get error - piece of traceback is included below.
>>
>> File "/usr/lib/pymodules/python2.7/**matplotlib/pyplot.py", line 343, in 
>> figure
>>
>> **kwargs)
>>   File 
>> "/usr/lib/pymodules/python2.7/**matplotlib/backends/backend_**tkagg.py", 
>> line 80, in new_figure_manager
>>
>> window = Tk.Tk()
>>   File "/usr/lib/python2.7/lib-tk/**Tkinter.py", line 1712, in __init__
>>
>> self.tk = _tkinter.create(screenName, baseName, className, interactive, 
>> wantobjects, useTk, sync, use)
>> TclError: no display name and no $DISPLAY environment variable
>>
>>
>> Google says this tclerror usually means that tk tries to get interactive,
>> but I thought matplotlib.use('Agg') should prevent that.
>> Any advice?
>> Thanks in advance.
>>
>  --
>
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/web2py/bNsGtWbV7AU/unsubscribe.
> To unsubscribe from this group and all its topics, 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: Process uploaded file and save it in Folder uploads

2013-07-17 Thread Gerd
Thank you Massimo, it worked

best regards
Gerd

Am Mittwoch, 17. Juli 2013 11:36:31 UTC+2 schrieb Massimo Di Pierro:
>
> Try this instead:
>
> request.vars.uploaded_file.file = StringIO.StringIO(data)
>
> On Wednesday, 17 July 2013 03:54:32 UTC-5, Gerd wrote:
>>
>> Hi!
>>
>> I have to anonymize HL7 file (replace all personal data with x). How can 
>> i process an uploaded file "on the fly". This is what i've tried (when it 
>> runs it actually saves the original file content, not the processed)
>>
>> *# Model*
>> db.define_table('filetypes',
>> Field('filetype','string'),
>> Field('seperator','string'),
>> Field('omit','string'),
>> format='%(filetype)s'
>> )
>>
>> db.define_table('anonymize',
>> Field('filetype','reference filetypes'),
>> Field('uploaded_file','upload')
>> )
>>
>> *# Controller*
>> def index():
>> """
>> example action using the internationalization operator T and flash
>> rendered by views/default/index.html or views/generic.html
>>
>> if you need a simple wiki simple replace the two lines below with:
>> return auth.wiki()
>> """
>> form = SQLFORM(db.anonymize)
>>
>> data = ''
>> import re
>> hl7 = 
>> {'PID':{'pattern':'PID\|','separator':'|','omit':(0,1,2,3)},'NK1':{'pattern':'NK1\|','separator':'|','omit':(0,)},'PV1':{'pattern':'PV1\|','separator':'|','omit':(0,)},'IN1':{'pattern':'IN1\|','separator':'|','omit':(0,)}}
>> if request.vars.uploaded_file != None and 
>> request.vars.uploaded_file.filename != '': 
>> if re.search('|'.join([hl7[k]['pattern'] for k in hl7]), 
>> request.vars.uploaded_file.value):
>> for line in request.vars.uploaded_file.value.splitlines():
>> replaced_text = ''
>> for k in hl7:
>> replaced_text = '|'.join([len(val) * 'x' if idx not 
>> in hl7[k]['omit'] else val for idx, val in enumerate([splitted_text for 
>> splitted_text in line.split(hl7[k]['separator'])])]) if 
>> re.search(hl7[k]['pattern'],line) else replaced_text
>> data += (replaced_text if replaced_text != '' else line) 
>> + '\n'
>> request.vars.uploaded_file.value = data
>> else:
>> data = 'No HL7 Format'
>> else:
>> data = u'No file chosen'
>>
>> if form.process().accepted:
>> response.flash = 'form accepted'
>> elif form.errors:
>> response.flash = 'form has errors'
>> return locals()
>>
>> I thought that the line
>> request.vars.uploaded_file.value = data
>> replaces the original data of the uploaded file, so that the 
>> form.process() processes the new (replaced) value
>>
>> What i am doing wrong here?
>>
>> Thanks,
>> Gerd
>>
>

-- 

--- 
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: Process uploaded file and save it in Folder uploads

2013-07-17 Thread Massimo Di Pierro
Try this instead:

request.vars.uploaded_file.file = StringIO.StringIO(data)

On Wednesday, 17 July 2013 03:54:32 UTC-5, Gerd wrote:
>
> Hi!
>
> I have to anonymize HL7 file (replace all personal data with x). How can i 
> process an uploaded file "on the fly". This is what i've tried (when it 
> runs it actually saves the original file content, not the processed)
>
> *# Model*
> db.define_table('filetypes',
> Field('filetype','string'),
> Field('seperator','string'),
> Field('omit','string'),
> format='%(filetype)s'
> )
>
> db.define_table('anonymize',
> Field('filetype','reference filetypes'),
> Field('uploaded_file','upload')
> )
>
> *# Controller*
> def index():
> """
> example action using the internationalization operator T and flash
> rendered by views/default/index.html or views/generic.html
>
> if you need a simple wiki simple replace the two lines below with:
> return auth.wiki()
> """
> form = SQLFORM(db.anonymize)
>
> data = ''
> import re
> hl7 = 
> {'PID':{'pattern':'PID\|','separator':'|','omit':(0,1,2,3)},'NK1':{'pattern':'NK1\|','separator':'|','omit':(0,)},'PV1':{'pattern':'PV1\|','separator':'|','omit':(0,)},'IN1':{'pattern':'IN1\|','separator':'|','omit':(0,)}}
> if request.vars.uploaded_file != None and 
> request.vars.uploaded_file.filename != '': 
> if re.search('|'.join([hl7[k]['pattern'] for k in hl7]), 
> request.vars.uploaded_file.value):
> for line in request.vars.uploaded_file.value.splitlines():
> replaced_text = ''
> for k in hl7:
> replaced_text = '|'.join([len(val) * 'x' if idx not in 
> hl7[k]['omit'] else val for idx, val in enumerate([splitted_text for 
> splitted_text in line.split(hl7[k]['separator'])])]) if 
> re.search(hl7[k]['pattern'],line) else replaced_text
> data += (replaced_text if replaced_text != '' else line) + 
> '\n'
> request.vars.uploaded_file.value = data
> else:
> data = 'No HL7 Format'
> else:
> data = u'No file chosen'
>
> if form.process().accepted:
> response.flash = 'form accepted'
> elif form.errors:
> response.flash = 'form has errors'
> return locals()
>
> I thought that the line
> request.vars.uploaded_file.value = data
> replaces the original data of the uploaded file, so that the 
> form.process() processes the new (replaced) value
>
> What i am doing wrong here?
>
> Thanks,
> Gerd
>

-- 

--- 
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] Submit several records to a table from one form

2013-07-17 Thread Andrey Oleynik
Hi!

I want to submit more than one record to a table from the form.

e.g. i have the following tables in the db:

db.define_table('book',

Field ('title')*)
**
*db.define_table('author',

Field ('name')
Field ('book', 'reference 
book'))


and function:

def submit():
form=SQLFORM 
.factory(db.book,db.author)
if form.process().accepted:
id = db.book.insert(**db.book._filter_fields(form.vars))
form.vars.book=id
id = db.author.insert(**db.author._filter_fields(form.vars))
response 
.flash='Thanks for filling 
the form'

return dict(form=form)

As result of submitting this form I gets by one record in each tables. 
How could I add more than one author of the book from the form without 
adding the authors in advance?

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] Have to delete @auth.requires_signature() fom default.py or app fails?

2013-07-17 Thread Jeremy Hankenson
Hello all, 
Just learning how to program for the web and creating a simple blog to 
learn off of. 

I created app called blog and a new controller called blog.py and a model 
called db.py. My blog controller looks like this:
def index():
return dict()

def create_post():
return dict()

def remove_post():
return dict()

def edit_post():
return dict()



My model is incredibly simple as can be. 
# -*- coding: utf-8 -*-

db = DAL("sqlite://blog.sqlite")

db.define_table('post',
Field('title', unique=True),
Field('author'),
Field('body', 'text'))

When I run my website blog, I get a error as such: 
 name 'auth' is not defined
but if I remove "@auth.requires_signature()" above the action "data" inside 
the "default.py" file. My application will run just fine. 

Why is this? What is the point of @auth.requires_signature() and why do I 
only get this error after creating a model?

Thank you very much, and thanks for the great framework!

-- 

--- 
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: python vs php reading sqlserver data

2013-07-17 Thread Massimo Di Pierro
What's the code? Anyway, web2py is expected to be slower then PHP. 4x seems 
a lot and perhaps optimizations are possible.

On Wednesday, 17 July 2013 03:39:46 UTC-5, Ramos wrote:
>
> Hello, i have a script in php to read data from an sqlserver.
> This script is running for the last 5 years in a pentium 4 computer.
>
> I converted this script using the same logic to python 
> in python i use SQLOLEDB.
>
> Running this code in python is 4 times slower in my intel core 3 than the 
> php one.
>
> Is this normal?
>
> Thank you
>  

-- 

--- 
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: can't compare datetime.date to Field

2013-07-17 Thread Massimo Di Pierro
Because the __lt__ operator is overloaded for the field object but not for 
the value (which can be int, float, etc.) If you have an idea about how to 
do that, let me know.



On Tuesday, 16 July 2013 21:57:02 UTC-5, lucas wrote:
>
> omg, that is amazing.  strange syntax.  why not interchangeable?  lucas
>>>
>>

-- 

--- 
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] Python script for Import data in MySQL

2013-07-17 Thread Rohitraj Sharma
I am using the flowing script, its ruining but did not import state table 


import csv


# initialize with empty ints and dicts
name,cities,countries,states=[],[],[],[]

with open('ind.csv','rb') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
reader.next() #skip header
for row in reader:
name.append(row[0])
cities.append(row[2])
states.append(row[3])
countries.append(row[4])
cl = list(set(countries))
sl = list(set(states))
citl = list(set(cities))
inf1 = list(set(name)) 



with open('countries.csv','w') as cfile:
writer = csv.writer(cfile, delimiter=',')
writer.writerow(['country_id','name'])
for i,x in enumerate(cl):
writer.writerow([i,x])

with open('state.csv','w') as cfile:
writer = csv.writer(cfile, delimiter=',')
writer.writerow(['state_id','country_id','state'])
for i,x in enumerate(sl):
writer.writerow([i,x,cl.index(countries[states.index(x)])])

with open('cities.csv','w') as cfile:
writer = csv.writer(cfile,delimiter=',')
writer.writerow(['city_id','city','st_id','country_id'])
for i,x in enumerate(citl):
writer.writerow([i,x,sl.index(states[cities.index(x)]),
 cl.index(countries[cities.index(x)])
 ])
 
 
with open('inf123.csv','w') as cfile:
writer = csv.writer(cfile,delimiter=',')
writer.writerow(['Name_id', 'Name','city_id','st_id','country_id'])
for i,x in enumerate(inf1):
writer.writerow([i,x,
citl.index(cities[name.index(x)]),
sl.index(states[name.index(x)]),
cl.index(countries[name.index(x)])
 ])

import MySQLdb 
import csv
mydb = MySQLdb.connect(host="localhost", # The Host 
user="root", # username 
passwd="root", # password 
db="abc") # name of the data base


cursor = mydb.cursor()

csv_data = csv.reader(file('countries.csv'))
for row in csv_data:

cursor.execute('INSERT INTO country(id, \
  name )' \
  'VALUES("%s", "%s")', 
  row)
#close the connection to the database.
mydb.commit()
cursor.close()
print "Done"


cursor = mydb.cursor()

csv_data = csv.reader(file('state.csv'))
for row in csv_data:

cursor.execute('INSERT INTO state(id, \
  country, name )' \
  'VALUES("%s", "%s", "%s")', 
  row)
#close the connection to the database.
mydb.commit()
cursor.close()
print "Done"



i am geting below error

csv_spliter.py:74: Warning: Incorrect integer value: ''country_id'' for 
column 'id' at row 1
  row)
csv_spliter.py:74: Warning: Incorrect integer value: ''0'' for column 'id' 
at row 1
  row)
csv_spliter.py:74: Warning: Incorrect integer value: ''1'' for column 'id' 
at row 1
  row)
csv_spliter.py:74: Warning: Incorrect integer value: ''2'' for column 'id' 
at row 1
  row)
csv_spliter.py:74: Warning: Incorrect integer value: ''3'' for column 'id' 
at row 1
  row)
Done
Traceback (most recent call last):
  File "csv_spliter.py", line 89, in 
row)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 174, in 
execute
self.errorhandler(self, exc, value)
  File "/usr/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, 
in defaulterrorhandler
raise errorclass, errorvalue
_mysql_exceptions.IntegrityError: (1452, 'Cannot add or update a child row: 
a foreign key constraint fails (`lcm`.`state`, CONSTRAINT `state_ibfk_1` 
FOREIGN KEY (`country`) REFERENCES `country` (`id`) ON DELETE CASCADE)') 

-- 

--- 
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: Deadlock found when trying to get lock; try restarting transaction

2013-07-17 Thread Massimo Di Pierro
We need more information. What is galera cluster? What you trying to lock?

On Tuesday, 16 July 2013 22:29:09 UTC-5, vince wrote:
>
> we are testing web2py with galera cluster and notice lots of Deadlock 
> found when trying to get lock; try restarting transaction ticket.
>
> those ticket don't come with request/session info, we have no idea where 
> and when did this problem occur. does that mean that web2py already handle 
> the retry?
>

-- 

--- 
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: Is there an issue with my web2py install? "can't pickle function objects"

2013-07-17 Thread Massimo Di Pierro
You are storing a function (or an object containing functions) in session.

On Tuesday, 16 July 2013 21:44:46 UTC-5, Joe Magaro wrote:
>
> Hi, Lately when I'm in the admin section, when I perform an action such as 
> installing a new app, or deleting a view I keep getting the error below. Im 
> not sure what changed to affect this, please help!
>
> raceback (most recent call last):
>   File "/home/www-data/web2py/gluon/main.py", line 606, in wsgibase
> session._try_store_in_cookie_or_file(request, response)
>   File "/home/www-data/web2py/gluon/globals.py", line 757, in 
> _try_store_in_cookie_or_file
> self._try_store_in_file(request, response)
>   File "/home/www-data/web2py/gluon/globals.py", line 763, in 
> _try_store_in_file
> if not response.session_id or self._forget or self._unchanged():
>   File "/home/www-data/web2py/gluon/globals.py", line 719, in _unchanged
> session_pickled = cPickle.dumps(dict(self))
>   File "/usr/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
> raise TypeError, "can't pickle %s objects" % base.__name__
> TypeError: can't pickle function objects
>
> Error snapshot [image: 
> help]
>
> (can't pickle function objects)
>

-- 

--- 
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 make app setup / is it possible to have modelless app?

2013-07-17 Thread Massimo Di Pierro
I often create a models/0.py file. In there

trigger = os.path.join(request.folder,'started')
if not os.path.exists(trigger):
 FIRST_RUN = True
 open(trigger,'w').write(str(request.now))
else:
 FIRST_RUN = False


On Tuesday, 16 July 2013 17:34:55 UTC-5, Dragan Matic wrote:
>
> What would be the best way to create an app setup? After 
> uploading/installing an app to a server I would like a user to be able to 
> start a setup page where he would choose a database/user/password and a few 
> other configuration parameters. Problem is that for every called page model 
> is executed and it wants to create a db object and create tables. Is it 
> possible to execute a controller without a model and execute a model only 
> after setting up database parameters?
>

-- 

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




[web2py] Re: how to use auth.wiki "extra" and "env"

2013-07-17 Thread Massimo Di Pierro
The correct syntax as far as the wiki is concerned is

@{join:a,b,c}

The problem is that MARKMIN identifies the call to "join" and the args 
"a,b,c" but it does not parse the args. You will have to do that:

def myjoin(vars):
 items = vars.split(',')
 if len(items)==3: return '-'.join(items)
 return 'Error!'

def index():
return auth.wiki(env=dict(join=myjoin)



On Tuesday, 16 July 2013 17:27:30 UTC-5, dhmorgan wrote:
>
> I'm experimenting with auth.wiki() using the book's instructions; using 
> web2py 2.60; created new simple app ("authwiki") via the admin wizard
>
>
> I'm attempting to utilize "@(join:a,b,c)" in the body of my wiki page, 
> having first set the controller to return auth.wiki(env=dict(join=lambda 
> a,b,c:"%s-%s-%s" % (a,b,c)))
>
> "@(join:a,b,c)" goes unrendered, as does "@join:a,b,c"
>
> "@{join:a,b,c}" and "@{join:(a,b,c)} both produce an error indicating:
>
> ERROR: () takes exactly 3 arguments (1 given)
>
>
> In controllers/default.py: 
>
> def index():
> return auth.wiki(env=dict(join=lambda a,b,c:"%s-%s-%s" % (a,b,c)))
>
>
> I also tried the same using "extra" instead of "env" in the auth.wiki() 
> call and got the same or similar results.
>
>
> This is the actual body text:
>
> - brackets and colon
>
> @{join:'how','you','doin'} 
>
> - brackets, colon and parenths
>
> @{join:('how','you','doin')}
>
> - parentheses and colon
>
> @(join:'how','you','doin')
>
> - colon only
>
> @join:'how','you','doin'
>
>

-- 

--- 
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: better calendar.js?

2013-07-17 Thread Massimo Di Pierro
Does anybody wants to attempt a replacement of the current calendar.js? We 
will have to check it works without bootstrap css.

On Tuesday, 16 July 2013 16:01:41 UTC-5, LightDot wrote:
>
> Looks nice. Probably worth looking into this...
>
> Regards,
> Ales
>
> On Thursday, July 11, 2013 9:26:15 PM UTC+2, Jim S wrote:
>>
>> I agree it is nicer and easier to use than the current date/time popup. 
>>  Yes, it does support time.  Is there a way it could be an optional feature 
>> you could turn on if you're using bootstrap?
>>
>> -Jim
>>
>> On Thursday, July 11, 2013 1:03:09 PM UTC-5, Massimo Di Pierro wrote:
>>>
>>> But we do not want the popup to break when people replace bootstrap with 
>>> a different style.
>>>
>>> On Thursday, 11 July 2013 12:19:33 UTC-5, VP wrote:

 Massimo:

 I just came across it, so I don't know 100% for sure.  But I think it 
 only depends on bootstrap which is included in web2py.



-- 

--- 
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: Serve images from action call or web service call

2013-07-17 Thread Massimo Di Pierro
This is easier than that.

First you create an action like this:

def serve_image():
id = request.args(0)
filename = get_image_filename_from(id)
stream = open(filename,'rb')
return response.stream(stream, attachment=True, filename=filename)

Then in your views you do:



where 1234 is the id of the image you want.

On Tuesday, 16 July 2013 14:36:09 UTC-5, Diego Carvallo wrote:
>
> I am using Web2Py and need to serve images from folder external to Web2py, 
> user images are dynamical and have to be loaded from a different system in 
> the same server therefore they cannot be moved to be contained in the 
> web2py application directory. So I cannot have a relative path to the 
> images. Symbolink links are not an option.
>
> I was thinking the solution could be to serve JPG images from an action 
> call or web service, this way the application can access the local file and 
> return it programatically without having to move a single image. For 
> example a view has the following code:
>
> 
>  
>   "controller_name/action_serving_images/unique_id_genereted_for_this_image.jpg"
>  
> alt="">
>  
> 
>
> having the Action:
> def action_serving_images(image_id)
> #obtain image based on it's unique generated id
> return image
>
> Or for the web service case:
> 
> 
>  "controller_name/service_serving_images/jpg/image/unique_id_genereted_for_this_image.jpg"
>  
> alt="">
> 
> 
>
> having the Service:
> def service_serving_images():
>  return service()
>
> @service.jpg
> def image(image_id):
> #obtain image based on it's unique generated id
> return image
>
>
>1. *Is any of these options possible?
>*
>2. *How can I fetch the image and return it as a byte stream with 
>the proper content-type so the browser can render it properly?
>*
>3. *Do i need to create a special decorator for JPG in the case of the 
>Service? How?*
>
>
> I posted the same question on 
> stackoverflow
>  but 
> no answer yet... I appreciate any help! 
>

-- 

--- 
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] Copy data from one db into another

2013-07-17 Thread Dave Carlson
Using the provided script cpdb.py and following the outlined procedure in 
the documentation (
http://web2py.com/books/default/chapter/29/06#Copy-data-from-one-db-into-another
) 

I get the following error 

* creating tables...*
*EXCEPTION: could not make a copy of the database*
*'NoneType' object is not iterable*

in this particular case, I've been using sqlite to build up a wiki and want 
to migrate the data to MariaDB, which I have installed, it is working and 
it is functioning correctly. Opening, connecting and I have used another 
app to interact with the database, before I attempted this copying process.

Any suggestions?

Thanks
Dave

-- 

--- 
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: new matplotlib tcl problem

2013-07-17 Thread Massimo Di Pierro
Based on this: github.com/web2py/web2py
you are right

On Tuesday, 16 July 2013 14:21:51 UTC-5, Marian Siwiak wrote:
>
> Hi,
>
> I try to run a module starting with:
>
> def mymodule(*variables*):
> import matplotlib
> matplotlib.use('Agg')
> from pymol import *
>
> When I call it, I get error - piece of traceback is included below.
>
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 343, in figure
> **kwargs)
>   File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", 
> line 80, in new_figure_manager
> window = Tk.Tk()
>   File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive, 
> wantobjects, useTk, sync, use)
> TclError: no display name and no $DISPLAY environment variable
>
>
> Google says this tclerror usually means that tk tries to get interactive, 
> but I thought matplotlib.use('Agg') should prevent that.
> Any advice? 
> Thanks in advance.
>

-- 

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




[web2py] Redirect in sqlform fails

2013-07-17 Thread Koen Vanhees
All,

this is the code in my controller:
def viewdata():
#id = request.vars.id
record = db1.data(request.vars.id)
form = SQLFORM(db1.data, record=record, submit_button="OK")

if form.process().accepted:
redirect(URL('second'))
return dict(form=form)

However, instead of being redirected to "second", it gets redirected to the 
same page with a "#" behind, and it displays a form with empty fields.
Moreover, if I add:
else:
redirect(URL('third'))

That redirection works even before the page loads.
What am I doing wrong?

Thanks in advance!

-- 

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




[web2py] Re: sqlform doesn't update after update_record

2013-07-17 Thread Massimo Di Pierro
This is a logic issue

result=db1(db1.data.id == request.vars.id).select().first()   
...
form = SQLFORM.factory(...  Field("Status", default = result.Status))
...
... form.process() ...

When the form is submitted (the action called the second time), the default 
value of the Field status is set to result.Status based on the value of the 
record before the form is processed, and therefore before the value of the 
record changes.

It should be:

... default = request.post_vars.get('Statu',result.Status) 

On Tuesday, 16 July 2013 13:23:07 UTC-5, Koen Vanhees wrote:
>
> All,
>
> I have a weird issue going on, although I'm obviously a newbie.
> This is my code (I have added some debugging stuff):
>
> def viewdata():
> msg2 = ""
> result2 = ""
> result=db1(db1.data.id == request.vars.id).select().first()   
> msg = str(result.Status)
> form = SQLFORM.factory(
> Field("Status", requires=IS_IN_SET(status_options), 
> default = result.Status),
> submit_button="Update")
> if form.process().accepted:
> if not result.Status == form.vars.Status: 
> result.update_record(Status=form.vars.Status)
> msg2 = str(result.Status)
> result2=db1(db1.data.id == request.vars.id).select().first()
> return dict(msg=msg,msg2=msg2,result=result,form=form,result2=result2)
>
> I load my page for the first time and this is the content:
> *msg *: New
> *msg2 *: 
> *result *:
> Status : 
> New
> delete_record : 
> 
> id : 
> 1L
> update_record : 
> 
> *result2 *:
>
> Then I change status to "Open" and click update, however, the form 
> refreshes and it still says "New"... msg seems to be stuck to "New"?:
> *msg *: 
> New
> *msg2 *: 
> Open
> *result *: 
> Status : 
> Open
> delete_record : 
> 
> id : 
> 1L
> update_record : 
> 
> *result2 *: 
> Status : 
> Open
> delete_record : 
> 
> id : 
> 1L
> update_record : 
> 
>
> Then if I set it back to "Open" and click update again, it refreshes 
> correctly and the form says "Open".  
> It always takes two actions before the form is updated, however the 
> entries in the database are correct.
>
> I'm probably missing something crucial here... Thanks in advance!
>

-- 

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




[web2py] Process uploaded file and save it in Folder uploads

2013-07-17 Thread Gerd
Hi!

I have to anonymize HL7 file (replace all personal data with x). How can i 
process an uploaded file "on the fly". This is what i've tried (when it 
runs it actually saves the original file content, not the processed)

*# Model*
db.define_table('filetypes',
Field('filetype','string'),
Field('seperator','string'),
Field('omit','string'),
format='%(filetype)s'
)

db.define_table('anonymize',
Field('filetype','reference filetypes'),
Field('uploaded_file','upload')
)

*# Controller*
def index():
"""
example action using the internationalization operator T and flash
rendered by views/default/index.html or views/generic.html

if you need a simple wiki simple replace the two lines below with:
return auth.wiki()
"""
form = SQLFORM(db.anonymize)

data = ''
import re
hl7 = 
{'PID':{'pattern':'PID\|','separator':'|','omit':(0,1,2,3)},'NK1':{'pattern':'NK1\|','separator':'|','omit':(0,)},'PV1':{'pattern':'PV1\|','separator':'|','omit':(0,)},'IN1':{'pattern':'IN1\|','separator':'|','omit':(0,)}}
if request.vars.uploaded_file != None and 
request.vars.uploaded_file.filename != '': 
if re.search('|'.join([hl7[k]['pattern'] for k in hl7]), 
request.vars.uploaded_file.value):
for line in request.vars.uploaded_file.value.splitlines():
replaced_text = ''
for k in hl7:
replaced_text = '|'.join([len(val) * 'x' if idx not in 
hl7[k]['omit'] else val for idx, val in enumerate([splitted_text for 
splitted_text in line.split(hl7[k]['separator'])])]) if 
re.search(hl7[k]['pattern'],line) else replaced_text
data += (replaced_text if replaced_text != '' else line) + 
'\n'
request.vars.uploaded_file.value = data
else:
data = 'No HL7 Format'
else:
data = u'No file chosen'

if form.process().accepted:
response.flash = 'form accepted'
elif form.errors:
response.flash = 'form has errors'
return locals()

I thought that the line
request.vars.uploaded_file.value = data
replaces the original data of the uploaded file, so that the form.process() 
processes the new (replaced) value

What i am doing wrong here?

Thanks,
Gerd

-- 

--- 
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] python vs php reading sqlserver data

2013-07-17 Thread António Ramos
Hello, i have a script in php to read data from an sqlserver.
This script is running for the last 5 years in a pentium 4 computer.

I converted this script using the same logic to python
in python i use SQLOLEDB.

Running this code in python is 4 times slower in my intel core 3 than the
php one.

Is this normal?

Thank you

-- 

--- 
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: can't compare datetime.date to Field

2013-07-17 Thread David Marko
I think this is because '>=' are methods on field object ...

Dne středa, 17. července 2013 4:57:02 UTC+2 lucas napsal(a):
>
> omg, that is amazing.  strange syntax.  why not interchangeable?  lucas
>>>
>>

-- 

--- 
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.