[web2py] Re: Minor optimize: skip superfish when possible

2011-12-28 Thread Ray (a.k.a. Iceberg)
Hi Massimo,

I just noticed that my second patch is derived from an old revision of
web2py skeleton app. It might not be directly patched the latest
trunk.

Anyway, this is what it tries to solve, and you can digest it and do
it again in the latest trunk.

1. Wrap all those {{=MENU(...)}} script type=text/javascript...
jQuery('ul.sf-menu')superfish(); ... /script inside the {{if
response.menu:}}...{{pass}} too

2. Add a long-lost parameter as: {{=MENU(..., li_active='current')}}

3. and then add a css snippet to make active menu distinguishing:
styleli.current {background:white; /* #BDD2FF; */}/style

Regards,
Ray

On Dec 27, 1:29 am, Ray (a.k.a. Iceberg) iceb...@21cn.com wrote:
 My fault. There should be one more modification.

 diff -r 04673c0ce6ab views/layout.html
 --- a/views/layout.html Tue Dec 27 01:29:01 2011 +0800
 +++ b/views/layout.html Tue Dec 27 01:29:17 2011 +0800
 @@ -39,8 +39,10 @@

      {{#--  require CSS and JS files for this page (read info in
 base.css) --}}
      {{response.files.append(URL('static','css/base.css'))}}
 -    {{response.files.append(URL('static','css/superfish.css'))}}
 -    {{response.files.append(URL('static','js/superfish.js'))}}
 +    {{if response.menu:}}
 +        {{response.files.append(URL('static','css/superfish.css'))}}
 +        {{response.files.append(URL('static','js/superfish.js'))}}
 +        {{pass}}
      {{#-- include web2py specific js code (jquery, calendar, form
 stuff) --}}
      {{include 'web2py_ajax.html'}}

 @@ -88,13 +90,14 @@

         div id=statusbar!-- statusbar is menu zone --
           {{block statusbar}} !-- this is default statusbar --
 -         {{#-- superfish menu --}}
 -      styleli.current {background:white; /* #BDD2FF; */}/style
 -      {{=MENU(response.menu,_class='sf-menu',li_active='current')}}
 -         script type=text/javascript
 -           jQuery(document).ready(function(){
 -           jQuery('ul.sf-menu').superfish();});
 -         /script
 +         {{if response.menu:}}{{#-- superfish menu --}}
 +          styleli.current {background:white; /* #BDD2FF; */}/
 style
 +          {{=MENU(response.menu,_class='sf-
 menu',li_active='current')}}
 +             script type=text/javascript
 +               jQuery(document).ready(function(){
 +               jQuery('ul.sf-menu').superfish();});
 +             /script
 +          {{pass}}
           div style=clear: both;/div!-- Clear the divs --
           {{end}}
         /div!-- statusbar --

 On Dec 27, 12:31 am, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:







  good idea. In trunk!

  On Dec 26, 9:32 am, Ray (a.k.a. Iceberg) iceb...@21cn.com wrote:

   Hey folks,

   I just use this little trick in my app, to reduce two unnecessary http
   requests when menus are not needed.

   I think the optimization is reasonable. And people can always manually
   re-enable superfish by response.files.extend([...]). So, my proposal
   is to put this into the default welcome (scaffold) app. Shall we?

   diff -r 483ebd275b49 views/layout.html
   --- a/views/layout.html Mon Dec 26 23:19:42 2011 +0800
   +++ b/views/layout.html Mon Dec 26 23:26:26 2011 +0800
   @@ -39,8 +39,10 @@

        {{#--  require CSS and JS files for this page (read info in
   base.css) --}}
        {{response.files.append(URL('static','css/base.css'))}}
   -    {{response.files.append(URL('static','css/superfish.css'))}}
   -    {{response.files.append(URL('static','js/superfish.js'))}}
   +    {{if response.menu:}}
   +        {{response.files.append(URL('static','css/superfish.css'))}}
   +        {{response.files.append(URL('static','js/superfish.js'))}}
   +        {{pass}}
        {{#-- include web2py specific js code (jquery, calendar, form
   stuff) --}}
        {{include 'web2py_ajax.html'}}


[web2py] SQLFORM.grid ignore_rw option

2011-12-28 Thread Dariel Dato-on
Hello!

When I pass the 'ignore_rw=True' to SQLFORM.grid(), not all the fields are 
displayed in the grid. The fields that are set to 'readable=False' are not 
displayed in the grid.

Is this the correct behavior? If so, how can I modify it?

Thanks!


Re: [web2py] Strikethrough with MARKMIN

2011-12-28 Thread Manuele Pesenti

Il 28/12/2011 07:08, lyn2py ha scritto:

How do I strikethrough some text using MARKMIN?

It's not available in the book, but I noticed that MARKMIN has a
strikethrough attribute.


use the source... young Skywalker! :)

M.


Thanks!




[web2py] auth.settings.login_onaccept NOT working as expected

2011-12-28 Thread david.waldrop
I have the following auth.settings :

# log system events
auth.settings.login_onaccept = lambda form:logactivity('Login','none')
auth.settings.profile_onaccept = lambda form:logactivity('Update 
Profile','none')
auth.settings.register_onaccept = lambda form:logactivity('Register','none')


which call the following function:

def logactivity(action, details):
db.log.insert(action=action, details=details)
return True


The log table is defined as follows:

#--Log--- 
db.define_table('log',
Field('action'),
Field('details'),
Field('created_by',db.auth_user,readable=False,writable=False),
Field('created_on','datetime',default=request.now, 
readable=False,writable=False),
migrate=migrate_db)
db.log.action.requires = IS_NOT_EMPTY()
db.log.details.requires = IS_NOT_EMPTY()
if auth.is_logged_in():
   db.log.created_by.default = auth.user.id  


The problem is the *created_by* field is not being set to the logged in 
user, but rather non.  The weird thing is the *created_on* is being set 
properly.  I suspect this has something to do with timing, but the 
documentation says onaccept happens after IO so I expected the auth.user 
object to be fully populated.  And ideas how I can fix this so the login 
action is logged in the table?





[web2py] Re: SQLFORM.grid ignore_rw option

2011-12-28 Thread Anthony
I believe the 'ignore_rw' argument to .grid() applies only to the 
create/view/edit forms (as with SQLFORM), not the grid. To get a field to 
appear in the grid, you probably have to explicitly set its 'readable' 
attribute to True.

Anthony

On Wednesday, December 28, 2011 2:53:57 AM UTC-5, Dariel Dato-on wrote:

 Hello!

 When I pass the 'ignore_rw=True' to SQLFORM.grid(), not all the fields are 
 displayed in the grid. The fields that are set to 'readable=False' are not 
 displayed in the grid.

 Is this the correct behavior? If so, how can I modify it?

 Thanks!



[web2py] Re: auth.settings.login_onaccept NOT working as expected

2011-12-28 Thread Anthony
On Wednesday, December 28, 2011 9:18:07 AM UTC-5, david.waldrop wrote:

 I have the following auth.settings :

 # log system events
 auth.settings.login_onaccept = lambda form:logactivity('Login','none')
 auth.settings.profile_onaccept = lambda form:logactivity('Update 
 Profile','none')
 auth.settings.register_onaccept = lambda 
 form:logactivity('Register','none')


 which call the following function:

 def logactivity(action, details):
 db.log.insert(action=action, details=details)
 return True


 The log table is defined as follows:

 #--Log--- 
 db.define_table('log',
 Field('action'),
 Field('details'),
 Field('created_by',db.auth_user,readable=False,writable=False),
 Field('created_on','datetime',default=request.now, 
 readable=False,writable=False),
 migrate=migrate_db)
 db.log.action.requires = IS_NOT_EMPTY()
 db.log.details.requires = IS_NOT_EMPTY()
 if auth.is_logged_in():
db.log.created_by.default = auth.user.id  


 The problem is the *created_by* field is not being set to the logged in 
 user, but rather non.  The weird thing is the *created_on* is being set 
 properly.  I suspect this has something to do with timing, but the 
 documentation says onaccept happens after IO so I expected the auth.user 
 object to be fully populated.  And ideas how I can fix this so the login 
 action is logged in the table?


You check if the user is logged in in the model file, but the user isn't 
actually logged in until later, after the controller processes the login 
credentials. Anyway, are you aware of the auth_event table -- the Auth 
system already logs all Auth activity in that table? 
See http://web2py.com/books/default/chapter/29/9#Access-Control.

Anthony


[web2py] Re: auth.settings.login_onaccept NOT working as expected

2011-12-28 Thread david.waldrop
Anthony, Thanks for the response.  I was NOT aware of the auth_event table. 
 In my case I still think I need my own log table as I am logging certain 
events in order to generate site specific activity metrics and think it 
would be convenient to collect all the activity in a single place.  Do you 
see anyway I can use the onaccept construct to update the log table with 
login.  I think this is the only situation I have an issue with.

Ins't it weird that after the onaccept callback the user is still not 
logged in?  what is the difference between onaccept and onvalidate then?


[web2py] Re: auth.settings.login_onaccept NOT working as expected

2011-12-28 Thread Anthony


 Ins't it weird that after the onaccept callback the user is still not 
 logged in?  what is the difference between onaccept and onvalidate then?


No, your problem is not that the user isn't logged in after onaccept -- 
it's that you test whether the user is logged in in your model file, and 
that test happens before the user is logged in (and therefore before the 
onaccept is called), so the default value never gets set. Here's the order:

1. model file:
 if auth.is_logged_in()  # user not logged in yet because login form input 
hasn't been processed yet

2. default.py controller:
def user():
return dict(form=auth())  # user gets logged in here, after the test in 
step 1

In other words, the login happens in the controller, but you're testing for 
login in a model file, before execution reaches the controller.

Maybe try:

db.log.insert(action=action, details=details, created_by=auth.user_id) 

Anthony




[web2py] Re: Strikethrough with MARKMIN

2011-12-28 Thread lyn2py
Appreciate answers / urls instead.
I found the strikethrough attribute through google.
I've searched through the book. MARKMIN doesn't say anything about
strikethroughs.
Is MARKMIN documentation complete? Or is strikethrough not recommended
to use yet?

If I understood the source I wouldn't be asking here.

On Dec 28, 8:09 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
 Il 28/12/2011 07:08, lyn2py ha scritto:

  How do I strikethrough some text using MARKMIN?

  It's not available in the book, but I noticed that MARKMIN has a
  strikethrough attribute.

 use the source... young Skywalker! :)

      M.







  Thanks!


Re: [web2py] Re: Strikethrough with MARKMIN

2011-12-28 Thread Martín Mulone
I think is not there, perhaps you can propose or pass extra argument.

Warning: I didn't test it.

extra = {'strike':lambda text: SPAN(text,
style='color:red;text-decoration:line-through').xml()}
MARKMIN(text, extra)


2011/12/28 lyn2py lyn...@gmail.com

 Appreciate answers / urls instead.
 I found the strikethrough attribute through google.
 I've searched through the book. MARKMIN doesn't say anything about
 strikethroughs.
 Is MARKMIN documentation complete? Or is strikethrough not recommended
 to use yet?

 If I understood the source I wouldn't be asking here.

 On Dec 28, 8:09 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
  Il 28/12/2011 07:08, lyn2py ha scritto:
 
   How do I strikethrough some text using MARKMIN?
 
   It's not available in the book, but I noticed that MARKMIN has a
   strikethrough attribute.
 
  use the source... young Skywalker! :)
 
   M.
 
 
 
 
 
 
 
   Thanks!




-- 
 http://martin.tecnodoc.com.ar


Re: [web2py] Re: Strikethrough with MARKMIN

2011-12-28 Thread Martín Mulone
I forget how to use it in content :P

`my text`:strike

2011/12/28 Martín Mulone mulone.mar...@gmail.com

 I think is not there, perhaps you can propose or pass extra argument.

 Warning: I didn't test it.

 extra = {'strike':lambda text: SPAN(text,
 style='color:red;text-decoration:line-through').xml()}
 MARKMIN(text, extra)


 2011/12/28 lyn2py lyn...@gmail.com

 Appreciate answers / urls instead.
 I found the strikethrough attribute through google.
 I've searched through the book. MARKMIN doesn't say anything about
 strikethroughs.
 Is MARKMIN documentation complete? Or is strikethrough not recommended
 to use yet?

 If I understood the source I wouldn't be asking here.

 On Dec 28, 8:09 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
  Il 28/12/2011 07:08, lyn2py ha scritto:
 
   How do I strikethrough some text using MARKMIN?
 
   It's not available in the book, but I noticed that MARKMIN has a
   strikethrough attribute.
 
  use the source... young Skywalker! :)
 
   M.
 
 
 
 
 
 
 
   Thanks!




 --
  http://martin.tecnodoc.com.ar




-- 
 http://martin.tecnodoc.com.ar


[web2py] Re: Strikethrough with MARKMIN

2011-12-28 Thread Massimo Di Pierro
even without the extra you should be able to do


style.strike {color:red;text-decoration:line-through}/style
{{=MARKMIN('.``text``:strike ')}}

unkown tags are mapped into classes.


On Dec 28, 10:29 am, Martín Mulone mulone.mar...@gmail.com wrote:
 I forget how to use it in content :P

 `my text`:strike

 2011/12/28 Martín Mulone mulone.mar...@gmail.com









  I think is not there, perhaps you can propose or pass extra argument.

  Warning: I didn't test it.

  extra = {'strike':lambda text: SPAN(text,
  style='color:red;text-decoration:line-through').xml()}
  MARKMIN(text, extra)

  2011/12/28 lyn2py lyn...@gmail.com

  Appreciate answers / urls instead.
  I found the strikethrough attribute through google.
  I've searched through the book. MARKMIN doesn't say anything about
  strikethroughs.
  Is MARKMIN documentation complete? Or is strikethrough not recommended
  to use yet?

  If I understood the source I wouldn't be asking here.

  On Dec 28, 8:09 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
   Il 28/12/2011 07:08, lyn2py ha scritto:

How do I strikethrough some text using MARKMIN?

It's not available in the book, but I noticed that MARKMIN has a
strikethrough attribute.

   use the source... young Skywalker! :)

        M.

Thanks!

  --
   http://martin.tecnodoc.com.ar

 --
  http://martin.tecnodoc.com.ar


[web2py] Re: Bug in widget.py: lack type='int' in new added --socket-timeout param

2011-12-28 Thread Carlos
Hi,

Not sure if this is the actual cause of my problem, but after loading this 
changeset (9619eb054669 / Socket timeout is now int an defaults to 60secs), 
multiple semi-concurrent requests from different browsers (IE / firefox / 
chrome / opera / safari) to the same page (web2py function) take a very 
long time or even fail, which was not happening prior to that change.

If I load the previous changeset, then it seems to work correctly.

I'm using latest trunk on win7.

Thanks.

   Carlos



[web2py] Re: How to make a function to download a file?

2011-12-28 Thread thstart
*As I see I need this:*
*  stream = cStringIO.StringIO() *
* return stream.getvalue() *
*
*
*I have a ready to go content as a string in a variable:*
*content = * '.'*
*

So how to put this string in a stream?

*My code is:*
*
*
*def download():
   response.headers['Content-Type'] = 'text/csv'
   attachment = 'attachment;filename=' + file+ '.csv'
   response.headers['Content-Disposition'] = attachment
   
   content = ',,'
   raise HTTP(200,str(content),
  **{'Content-Type':'text/csv',
 'Content-Disposition':attachment + ';'})*
*
*



[web2py] Re: (Another) Blog Engine in web2py

2011-12-28 Thread Joseph Jude
Power of web2py is in running the same code base both in GAE  webfaction. 
Here is the blog engine (with imported wordpress entries) in webfaction: 
http://www.jjude.biz

I wrote about it here: http://goo.gl/zidxe

Let 2012 be a great year.

Joseph


[web2py] Re: How to make a function to download a file?

2011-12-28 Thread Anthony
On Wednesday, December 28, 2011 1:05:43 PM UTC-5, thstart wrote:

 *As I see I need this:*
 *  stream = cStringIO.StringIO() *
 * return stream.getvalue()*


Actually, that will do the same thing you've already tried 
(stream.getvalue() is just a string, so you'll be returning a string, just 
like your original code). In fact, when I try your original code, it works 
fine, so perhaps your problem is with the link or routing (i.e., the link 
isn't properly routing to the download function). Also, in your code, where 
does the 'file' variable come from?

Anthony


[web2py] write view into an html file

2011-12-28 Thread Adi
I have a nicely formatted HTML displayed in a view, but now need to save it 
as PDF. 

Is there any approach where it wouldn't be necessary to reformat the 
document again, instead just save HTML as PDF? 

Tried using generic.pdf, but got the error that PIL is missing, and also 
when I tried to save HTML in a file (through one of the examples from the 
forum), it didn't save the HTML, instead it save unformatted data. 
open(filename,'wb').write(response.render(view_content, dict(conf=conf, 
po=po, skus=skus))) 

Any advice? 

Thanks,
Adi



[web2py] Re: write view into an html file

2011-12-28 Thread Paolo Caruccio
try the solution in this discussion 
https://groups.google.com/d/topic/web2py/GyQ8_szQFoI/discussion

Happy Holidays.




[web2py] Re: Many-to-many admin form

2011-12-28 Thread Christopher Steel
OK,

Here are some resources you will want to check out if you have not found 
them on your own already.

# Web2py Plugins
## http://web2py.com/plugins/default

### looks good
http://web2py.com/plugins/default/tagging

### interesting
http://web2py.com/plugins/default/multiselect
http://web2py.com/plugins/default/dropdown


# Powerform
## http://labs.blouweb.com/powerformwizard
Multi table forms


# http://dev.s-cubism.com/web2py_plugins
## Other the top functionality, slightly bleeding edge:

http://dev.s-cubism.com/plugin_multiselect_widget
http://dev.s-cubism.com/plugin_solidform




[web2py] Re: How to make a function to download a file?

2011-12-28 Thread thstart
file is composed dynamically - I get it from request - it is send like 
?file=name and I get it from there.

can you post the code you just tried?


[web2py] Re: How to make a function to download a file?

2011-12-28 Thread Anthony
I literally just copied and pasted your code into a basic 'welcome' app, 
except I hard-coded a filename (data.csv):

def download():
response.headers['Content-Type'] = 'text/csv'
attachment = 'attachment;filename=data.csv'
response.headers['Content-Disposition'] = attachment
content = ',,'
raise HTTP(200,str(content),
   **{'Content-Type':'text/csv',
  'Content-Disposition':attachment + ';'})

Then I entered that URL in my browser address bar, and I got a CSV file 
download, which opened right up in Excel (it included one row of data, with 
... in each of the three first columns).

Anthony

On Wednesday, December 28, 2011 3:55:12 PM UTC-5, thstart wrote:

 file is composed dynamically - I get it from request - it is send like 
 ?file=name and I get it from there.

 can you post the code you just tried?



[web2py] Re: How to make a function to download a file?

2011-12-28 Thread thstart
You mean my original code is working? With IE it is not.
What browser you are using? In IE nothing comes
for download.


Re: [web2py] Re: Many-to-many admin form

2011-12-28 Thread Bruce Wade
OK thanks, I will take a look through the resources you have provided.

--
Regards,
Bruce

On Wed, Dec 28, 2011 at 12:35 PM, Christopher Steel
chris.st...@gmail.comwrote:

 OK,

 Here are some resources you will want to check out if you have not found
 them on your own already.

 # Web2py Plugins
 ## http://web2py.com/plugins/default

 ### looks good
 http://web2py.com/plugins/default/tagging

 ### interesting
 http://web2py.com/plugins/default/multiselect
 http://web2py.com/plugins/default/dropdown


 # Powerform
 ## http://labs.blouweb.com/powerformwizard
 Multi table forms


 # http://dev.s-cubism.com/web2py_plugins
 ## Other the top functionality, slightly bleeding edge:

 http://dev.s-cubism.com/plugin_multiselect_widget
 http://dev.s-cubism.com/plugin_solidform





-- 
-- 
Regards,
Bruce Wade
http://ca.linkedin.com/in/brucelwade
http://www.wadecybertech.com
http://www.warplydesigned.com
http://www.fitnessfriendsfinder.com


[web2py] compute on update

2011-12-28 Thread Richard Vézina
Hello,

I would like to compute a field on update, but I think all the request.vars
needed to my lambda compute function are not passed to form.vars...

What I should do to make sure all the needed vars are available to the
lambda compute function?

form.vars.varname = request.vars.varname ??

Thanks

Richard


[web2py] How to set custom CSS classes for SQLFORM widget input in web2py

2011-12-28 Thread Kenny Meyer
http://stackoverflow.com/questions/8661166/custom-css-classes-for-sqlform-widget-input-in-web2py


[web2py] Re: How to make a function to download a file?

2011-12-28 Thread Anthony
I literally copied your exact code (just had to hard-code the filename):

def download():
response.headers['Content-Type'] = 'text/csv'
attachment = 'attachment;filename=data.csv'
response.headers['Content-Disposition'] = attachment
content = ',,'
raise HTTP(200,str(content),
   **{'Content-Type':'text/csv',
  'Content-Disposition':attachment + ';'})

Then I entered that URL in my browser and I got the CSV file download, with 
the content as above.

Anthony

On Wednesday, December 28, 2011 3:55:12 PM UTC-5, thstart wrote:

 file is composed dynamically - I get it from request - it is send like 
 ?file=name and I get it from there.

 can you post the code you just tried?



Re: [web2py] Re: new appliances - Happy Holidays

2011-12-28 Thread Khalil KHAMLICHI
Good work.


[web2py] Re: How to set custom CSS classes for SQLFORM widget input in web2py

2011-12-28 Thread Alan Etkin
It is possible to iterate trough any input element within the form
object with this command

for f in form.elements(input):...

Sequences of objects can be retrieved with the css like syntax:

element sub-element
element.class
element[type=submit]

Where form is a SQLFORM instance

And class input attribute can be set inside the loop with this:

f[_class] = custom class name string

On 28 dic, 17:52, Kenny Meyer knny.m...@gmail.com wrote:
 http://stackoverflow.com/questions/8661166/custom-css-classes-for-sql...


[web2py] Re: How to set custom CSS classes for SQLFORM widget input in web2py

2011-12-28 Thread Anthony
Answer: http://stackoverflow.com/a/8661906/440323

On Wednesday, December 28, 2011 3:52:04 PM UTC-5, Kenny Meyer wrote:


 http://stackoverflow.com/questions/8661166/custom-css-classes-for-sqlform-widget-input-in-web2py



[web2py] Re: How to set custom CSS classes for SQLFORM widget input in web2py

2011-12-28 Thread Alan Etkin
And you might consider defining the class attribute with a custom
widget for the css to be available to all app forms.

Custom widgets are covered in the web2py book (7.7)

On 28 dic, 19:42, Alan Etkin spame...@gmail.com wrote:
 It is possible to iterate trough any input element within the form
 object with this command

 for f in form.elements(input):...

 Sequences of objects can be retrieved with the css like syntax:

 element sub-element
 element.class
 element[type=submit]

 Where form is a SQLFORM instance

 And class input attribute can be set inside the loop with this:

 f[_class] = custom class name string

 On 28 dic, 17:52, Kenny Meyer knny.m...@gmail.com wrote:

 http://stackoverflow.com/questions/8661166/custom-css-classes-for-sql...




[web2py] Re: How to make a function to download a file?

2011-12-28 Thread Anthony
On Wednesday, December 28, 2011 4:10:55 PM UTC-5, thstart wrote:

 You mean my original code is working? With IE it is not.
 What browser you are using? In IE nothing comes
 for download.


Works in IE7 and IE9 for me. Are you clicking a link or going directly to 
/appname/controller/download in the browser? Perhaps the link is incorrect 
or there's a problem with the filename (though not sure that would affect 
the download). Also, note that the default.py controller of the 'welcome' 
app already includes a download() function -- if you've added a second 
download function to that controller, I think that will cause a problem.

Anthony 


Re: [web2py] Re: How to make a function to download a file?

2011-12-28 Thread Constantine Vasil
I fired the debugger, when I click on the link,
the debugger stops at the function (the name is export),

it comes down to  raise HTTP but does not downloads
the file.

On Wed, Dec 28, 2011 at 2:56 PM, Anthony abasta...@gmail.com wrote:

 On Wednesday, December 28, 2011 4:10:55 PM UTC-5, thstart wrote:

 You mean my original code is working? With IE it is not.
 What browser you are using? In IE nothing comes
 for download.


 Works in IE7 and IE9 for me. Are you clicking a link or going directly to
 /appname/controller/download in the browser? Perhaps the link is incorrect
 or there's a problem with the filename (though not sure that would affect
 the download). Also, note that the default.py controller of the 'welcome'
 app already includes a download() function -- if you've added a second
 download function to that controller, I think that will cause a problem.

 Anthony



Re: [web2py] Re: Record Versioning

2011-12-28 Thread Khalil KHAMLICHI
If you are using mysql db, you can try to use triggers instead of all of
this.


[web2py] Re: How to set custom CSS classes for SQLFORM widget input in web2py

2011-12-28 Thread Anthony
On Wednesday, December 28, 2011 5:50:53 PM UTC-5, Alan Etkin wrote:

 And you might consider defining the class attribute with a custom 
 widget for the css to be available to all app forms. 


Good suggestion. Note, you don't necessarily need to create a custom widget 
-- you can pass HTML attributes to any widget via a lambda:

db.mytable.myfield.widget = lambda field, value: 
SQLFORM.widgets.string.widget(field, value, _class='my-string')


Anthony


Re: [web2py] Re: How to make a function to download a file?

2011-12-28 Thread Anthony
Not sure what the problem is. What version of web2py? Can you attach a 
minimal app that reproduces the problem?

On Wednesday, December 28, 2011 5:58:03 PM UTC-5, thstart wrote:

 I fired the debugger, when I click on the link,
 the debugger stops at the function (the name is export),

 it comes down to  raise HTTP but does not downloads
 the file.

 On Wed, Dec 28, 2011 at 2:56 PM, Anthony abas...@gmail.com wrote:

 On Wednesday, December 28, 2011 4:10:55 PM UTC-5, thstart wrote:

 You mean my original code is working? With IE it is not.
 What browser you are using? In IE nothing comes
 for download.


 Works in IE7 and IE9 for me. Are you clicking a link or going directly to 
 /appname/controller/download in the browser? Perhaps the link is incorrect 
 or there's a problem with the filename (though not sure that would affect 
 the download). Also, note that the default.py controller of the 'welcome' 
 app already includes a download() function -- if you've added a second 
 download function to that controller, I think that will cause a problem.

 Anthony 




[web2py] Re: Strikethrough with MARKMIN

2011-12-28 Thread lyn2py
Thanks Massimo and Martin! Didn't realize that MARKMIN has this
feature


On Dec 29, 12:38 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 even without the extra you should be able to do

 style.strike {color:red;text-decoration:line-through}/style
 {{=MARKMIN('.``text``:strike ')}}

 unkown tags are mapped into classes.

 On Dec 28, 10:29 am, Martín Mulone mulone.mar...@gmail.com wrote:







  I forget how to use it in content :P

  `my text`:strike

  2011/12/28 Martín Mulone mulone.mar...@gmail.com

   I think is not there, perhaps you can propose or pass extra argument.

   Warning: I didn't test it.

   extra = {'strike':lambda text: SPAN(text,
   style='color:red;text-decoration:line-through').xml()}
   MARKMIN(text, extra)

   2011/12/28 lyn2py lyn...@gmail.com

   Appreciate answers / urls instead.
   I found the strikethrough attribute through google.
   I've searched through the book. MARKMIN doesn't say anything about
   strikethroughs.
   Is MARKMIN documentation complete? Or is strikethrough not recommended
   to use yet?

   If I understood the source I wouldn't be asking here.

   On Dec 28, 8:09 pm, Manuele Pesenti manuele.pese...@gmail.com wrote:
Il 28/12/2011 07:08, lyn2py ha scritto:

 How do I strikethrough some text using MARKMIN?

 It's not available in the book, but I noticed that MARKMIN has a
 strikethrough attribute.

use the source... young Skywalker! :)

     M.

 Thanks!

   --
    http://martin.tecnodoc.com.ar

  --
   http://martin.tecnodoc.com.ar


[web2py] AttributeError: 'thread._local' object has no attribute '_scheduled'

2011-12-28 Thread Brian M
This is simply a note for anybody else who may come across this error when 
trying to run web2py's scheduler - it works just fine, provided you 
actually set it up in your code. (As great as web2py is, it is not psychic)

python web2py.py -K myapp
...
AttributeError: 'thread._local' object has no attribute '_scheduled'

If you get the error make sure you've actually imported the scheduler in 
one of your app's models. 

from gluon.scheduler import Scheduler
myscheduler = Scheduler(db, dict(task_name = task_function))

I just wasted a bunch of time trying to figure out what was wrong only to 
finally realize that I was trying to run the scheduler against the wrong 
version of my app - one that I hadn't yet setup the scheduler in. DOH!  I 
hope that sharing my foolishness here might save someone else a bit of 
frustration in the future. :)

~Brian


[web2py] Re: write view into an html file

2011-12-28 Thread Adi
Thanks Paolo for your advice. 

What do you have to install to get the plugin working? If I understood 
properly, appreport plugin depends on xhtml2pdf, and that one depends on 
two-three other libraires:
Reportlab Toolkit 2.2+
html5lib 0.11.1+
pyPdf 1.11+ (optional)

Is this the only way how to convert  HTML+CSS to pdf? 

Is there any way to programatically save into a file rendered HTML as it is 
displayed in a browser? 

Thanks and Happy Holidays to you too!



[web2py] Re: write view into an html file

2011-12-28 Thread Adi
got the html export into file working with code bellow: 

# write view html into file
conf, po, skus = get_data(65)# test data
view_template = os.path.join(request.folder, 'views/default', 
'print_proforma_invoice.html')
html = response.render(view_template, dict(conf=conf, po=po, skus=skus))
filename=test-dec-pdf-po-28.html # test output file name
open(filename,'wb').write(response.render(view_template, 
dict(conf=conf, po=po, skus=skus)))

but it seems the PDF part creation triggered an error while rendering CSS 
in pyfpdf/html.py. (100px was a width of an image, specified in css)

If it's of any value to anyone, here is a trackback bellow:

type 'exceptions.ValueError' invalid literal for int() with base 10: 
'100px'

traceback:

Traceback (most recent call last):
  File /Users/adnan/web2py-dev-branch/gluon/restricted.py, line 204, in 
restricted
exec ccode in environment
  File 
/Users/adnan/web2py-dev-branch/applications/Wholesale/controllers/default.py 
http://127.0.0.1:8000/admin/default/edit/Wholesale/controllers/default.py, 
line 596, in module
  File /Users/adnan/web2py-dev-branch/gluon/globals.py, line 172, in lambda
self._caller = lambda f: f()
  File 
/Users/adnan/web2py-dev-branch/applications/Wholesale/controllers/default.py 
http://127.0.0.1:8000/admin/default/edit/Wholesale/controllers/default.py, 
line 580, in myreport
pdf.write_html(html)
  File /Users/adnan/web2py-dev-branch/gluon/contrib/pyfpdf/html.py, line 388, 
in write_html
h2p.feed(text)
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py,
 line 108, in feed
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py,
 line 148, in goahead
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py,
 line 269, in parse_starttag
  File 
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/HTMLParser.py,
 line 325, in handle_startendtag
  File /Users/adnan/web2py-dev-branch/gluon/contrib/pyfpdf/html.py, line 257, 
in handle_starttag
w = px2mm(attrs.get('width', 0))
  File /Users/adnan/web2py-dev-branch/gluon/contrib/pyfpdf/html.py, line 17, 
in px2mm
return int(px)*25.4/72.0
ValueError: invalid literal for int() with base 10: '100px'



[web2py] Suggestion: db stats in response.toolbar format

2011-12-28 Thread lyn2py
Hi Massimo,

1.99.4 stable

The db stats in response.toolbar is one long single line, which is
less readable than 1.99.2 (a lot of scrolling).
Perhaps the readability can be improved for future versions (use the
format in 1.99.2?).

Thanks!


[web2py] How to use SELECT Tag (HTML HELP) to print out a list

2011-12-28 Thread Dan
Hi everyone,

Happy holidays first.

How do I use the the Web2Python HTML Helper =SELECT Tag to print out
a select with all contents in a list.
like following one

select
{{for i in ['a','b','c']:}}
option{{=i}} /option
{{pass}}
/select

Many thanks.


[web2py] Field vs id

2011-12-28 Thread JF
I think this information was actually somewhere in previous Books, but I 
just can't find it anymore in the 4th version.
 
I would like to be able to get to a record, let's say from a function 
called edit.  But using a Field from the table, not the id of the table.
 
Example:
This is accessed through the id of a record in a table.
http://127.0.0.1:8000/partcreation/item/edit/1
 
But I would like to access it through a Field from the same table.  
Obviously this name/number must be unique.
http://127.0.0.1:8000/partcreation/item/edit/2122-123456789-00
 
Note that the URL above is not working.  I would like to know what would be 
the URL (and the code to put in the function) to use 2122-123456789-00 
instead of 1.
 
Thanks,
JF


Re: [web2py] How to use SELECT Tag (HTML HELP) to print out a list

2011-12-28 Thread Bruno Rocha
*SELECT(*[OPTION(i) for i in ['a', 'b', 'c']])*

On Thu, Dec 29, 2011 at 4:52 AM, Dan ideall...@googlemail.com wrote:

 select
 {{for i in ['a','b','c']:}}
 option{{=i}} /option
 {{pass}}
 /select




-- 

Bruno Rocha
[http://rochacbruno.com.br]


[web2py] Re: How to use SELECT Tag (HTML HELP) to print out a list

2011-12-28 Thread Dan
Gotcha, thanks a lot.

On Dec 29, 2:55 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 *SELECT(*[OPTION(i) for i in ['a', 'b', 'c']])*

 On Thu, Dec 29, 2011 at 4:52 AM, Dan ideall...@googlemail.com wrote:
  select
  {{for i in ['a','b','c']:}}
  option{{=i}} /option
  {{pass}}
  /select

 --

 Bruno Rocha
 [http://rochacbruno.com.br]