Re: [web2py] Merry Christmas everybody!

2012-12-25 Thread Martín Mulone
Merry Christmast!


2012/12/25 ゴー・ニコライ nikolai...@gmail.com

 Happy Festivus!


 On Tuesday, December 25, 2012, Massimo Di Pierro wrote:

 Merry Christmas everybody!

 --




  --







-- 
http://martinmulone.com.ar

-- 





Re: [web2py] Re: fall back for memcached to db caching

2012-12-25 Thread Adnan Smajlovic
What I wanted to do is when there is no memcache installed, or something
happens to it while running, the application should switch automatically to
db sessions, rather than just throw an error.

The code I got bellow re-creates the problem, but if I add an extra if
notsession
: session.connect(request, response, db=db) it works fine for my purposes.

Sorry that I'm explaining this upside-down :)


On Tue, Dec 25, 2012 at 1:23 AM, Massimo Di Pierro 
massimo.dipie...@gmail.com wrote:

 I am not sure I fully understand the problem.

 One issue is that you cannot do:

 try:
   redirect(url)
 except:
   something

 you have to do

 try:
   redirect(url)
 except HTTP, e:
   raise e
 except:
   db.rollback() # maybe
   something

 because a redirect will raise HTTP which extends Exception. You need to
 re-reise it for it to work.

 Massimo

 On Tuesday, 25 December 2012 00:01:19 UTC-6, Adi wrote:

 Thanks Massimo. The exception works fine, but the problem raised when
 calling a grid. Didn't realize it's not possible to connect to another
 session within the except segment. Seems that code has to be outside.
 Still learning python here :)


 db.py
 -
 try:
 from gluon.contrib.memcache import MemcacheClient
 memcache_servers = ['127.0.0.1:11211']
 cache.memcache = MemcacheClient(request, memcache_servers)
 cache.ram = cache.disk = cache.memcache
 from gluon.contrib.memdb import MEMDB
 session.connect(request,respon**se,db=MEMDB(cache.memcache))
 except Exception:
 session.connect(request, response, db=db) # doesn't work
 pass

 # had to do it this way, and then all works as expected
 if not session:
 session.connect(request, response, db=db)

 db.define_table('mytable',Fiel**d('myfield','string'))


 default.py
 --
 def gr():
 q = (db.mytable.id0)
 grid=SQLFORM.grid(q)
 return dict()









 On Monday, December 24, 2012 5:11:17 PM UTC-5, Massimo Di Pierro wrote:

 Can you try replace:

 except:

 with

 except Exception:

 On Monday, 24 December 2012 10:04:08 UTC-6, Adi wrote:

 Tried catching the exception when memcache is not available to switch
 to db caching, but getting an excepting.

 Should it be possible to catch this exception, ignore it and continue
 running?

 Thanks,
 Adnan


 try:
 from gluon.contrib.memcache import MemcacheClient
 memcache_servers = ['127.0.0.1:11211']
 cache.memcache = MemcacheClient(request, memcache_servers)
 cache.ram = cache.disk = cache.memcache
 from gluon.contrib.memdb import MEMDB
 session.connect(request,respon**se,db=MEMDB(cache.memcache))
 except:
 sys.exc_clear()
 session.connect(request, response, db=db)
 pass



 Traceback (most recent call last):
  File /Users/adnan/web2py24/gluon/**main.py, line 557, in wsgibase
  session._try_store_in_db(requ**est, response)
  File /Users/adnan/web2py24/gluon/**globals.py, line 739, 
 in_try_store_in_db
  record_id = table.insert(**dd)
  File /Users/adnan/web2py24/gluon/**contrib/memdb.py, line 256, ininsert
  id = self._create_id()
  File /Users/adnan/web2py24/gluon/**contrib/memdb.py, line 296, 
 in_create_id
  raise Exception('cannot set memcache')
 Exception: cannot set memcache



 Frames



  File /Users/adnan/web2py24/gluon/ma**in.py in wsgibase at line 557
 code arguments variables



  File /Users/spa...
 Show 
 originalhttps://groups.google.com/group/web2py/msg/154fffb31c2a7321?dmode=sourceoutput=gplainnoredirect

  --





-- 





[web2py] How to set/reset administrator password (apache+wsgi+windows)

2012-12-25 Thread at

Hi

After setting up web2py+apache with wsgi on windows, I can see web2py admin 
page at http://localhost/admin/default/index. But it is asking password to 
log into the administrative interface. How to set a password? Is there any 
default password for first time entrance?

Thanks
AT


-- 





[web2py] Smartgrid question.

2012-12-25 Thread dev . ldhughes
I am using a smartgrid to manage users and include a button that when 
selected will show a list of groups the user is a member of.  I am using 
the latest release of web2py, v2.3.2 and  when I set 
linked_tables=['auth_membership'] I end up with three buttons, 
[Auth_memberships(user_id)], [Auth_memberships(created_by)] and 
[Auth_memberships(created_by)].  The [Auth_memberships(user_id)] button 
shows the information that I want.  but I only want the one button. How do 
I not show the other two buttons?


-- 





[web2py] Re: Concurrent HTTP requests (Ajax call blocking other requests)

2012-12-25 Thread raphael . benedet
Hello,

I'm a little confused here... I tried to put your code in the models (I 
suppose you mean db.py) as you suggest but it didn't work. Then, I put it 
in the controller for this AJAX method and it didn't work either. After 
that, I modified your code to unlock the response instead of the request 
and it worked.

I ended up using session.forget(response) (which seems to be the official 
documented method) in my AJAX controller and it works. But... am I doing it 
right?

Merry Christmas,
Raphael

Le lundi 24 décembre 2012 19:29:36 UTC+1, Massimo Di Pierro a écrit :

 No this is a feature which can be disabled. Web2py serializes all 
 requests from the same user by locking sessions. You can do in your models:

 if request.ajax: session._unlock(request)

 Massimo

 On Monday, 24 December 2012 10:31:57 UTC-6, raphael...@netaxis.be wrote:

 Hello,
 My application performs Ajax calls to dynamically retrieve and display 
 the content of a log. If there is no change (no new lines) to the log 
 compared to the previous Ajax request, the contoller holds the request for 
 up to 5 secs (Ajax long polling).
 The problem is that when the controller holds an Ajax request, other HTTP 
 requests like click on normal a href... links are blocked until the Ajax 
 call completes.
 Is this due to a limit to the number of requests per client?
 Best Regards,
 Raphael



-- 





Re: [web2py] Re: basics of DOM manipulation with web2py

2012-12-25 Thread Anthony


 But what about the DOM objects like radio buttons, text area etc in the 
 html ?. When the view file is processed and the response object is working 
 on it to generate pure HTML , won't it create a DOM tree structure in 
 memory. ?.


No, if you just hand code the form HTML in the view but never create a FORM 
or SQLFORM object, you don't get any server-side DOM. The server-side DOM 
comes only with the use of the HTML helpers. If you want to take advantage 
of the FORM DOM on the server but still want to customize your HTML, check 
out http://web2py.com/books/default/chapter/29/07#Custom-forms.

There are also other benefits of using FORM and SQLFORM in the controller 
-- they automatically validate user inputs and return and display error 
messages upon invalid input, and they add a special formkey token to the 
form to prevent CSRF attacks and double form submission.

Anthony 

-- 





Re: [web2py] Re: Graph Model (proposal to contribute)

2012-12-25 Thread Jose


El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro 
escribió:

 Not yet. It is the queue.


Hello Massimo.

I saw this and was implemented in the trunk.

A new application is created from the welcome folder or from welcome.w2p?
I created an application and is not available the code that implements 
graph model.

Best Regards
Jose 

-- 





[web2py] Re: Concurrent HTTP requests (Ajax call blocking other requests)

2012-12-25 Thread Anthony
Yes, you have it right -- you can do session.forget(response) or 
session._unlock(response) (the former ultimately calls the latter).

Anthony

On Tuesday, December 25, 2012 3:58:00 AM UTC-5, raphael...@netaxis.be wrote:

 Hello,

 I'm a little confused here... I tried to put your code in the models (I 
 suppose you mean db.py) as you suggest but it didn't work. Then, I put it 
 in the controller for this AJAX method and it didn't work either. After 
 that, I modified your code to unlock the response instead of the request 
 and it worked.

 I ended up using session.forget(response) (which seems to be the official 
 documented method) in my AJAX controller and it works. But... am I doing it 
 right?

 Merry Christmas,
 Raphael

 Le lundi 24 décembre 2012 19:29:36 UTC+1, Massimo Di Pierro a écrit :

 No this is a feature which can be disabled. Web2py serializes all 
 requests from the same user by locking sessions. You can do in your models:

 if request.ajax: session._unlock(request)

 Massimo

 On Monday, 24 December 2012 10:31:57 UTC-6, raphael...@netaxis.be wrote:

 Hello,
 My application performs Ajax calls to dynamically retrieve and display 
 the content of a log. If there is no change (no new lines) to the log 
 compared to the previous Ajax request, the contoller holds the request for 
 up to 5 secs (Ajax long polling).
 The problem is that when the controller holds an Ajax request, other 
 HTTP requests like click on normal a href... links are blocked until the 
 Ajax call completes.
 Is this due to a limit to the number of requests per client?
 Best Regards,
 Raphael



-- 





[web2py] Problem with routing

2012-12-25 Thread elyase
I have two controllers 'default.py' and 'error.py'. In my website 
www.cubadena.com, if I try to access www.cubadena.com/default it correctly 
redirects to the index() function inside the default controller, but if I 
do the same with www.cubadena.com/error/ I get a: 

Not FoundThe requested URL /error/ was not found on this server.

Looking at the server logs I see a Attempt to serve directory: 
/var/www/error/ error. How is this possible? I have both controller files 
inside the web2py controller folder, and corresponding index.html files 
inside a 'default' and 'error' folders in the application views folder. 
Another curious thing is that if I add the application name to the URL it 
works as expected for example: www.cubadena.com/cubadena/error (works!!)

This is how my web2py routes.py looks like:

routers = dict(
BASE=dict(default_application='cubadena'),
cubadena=dict(languages=['en', 'es'], default_language='es'),
)

routes_onerror = [(r'*/*', r'/cubadena/error/index')]

What can I do to correct this behaviour?

-- 





Re: [web2py] Re: basics of DOM manipulation with web2py

2012-12-25 Thread Bhaskar Ramachandran
Great!. Thank you all for the clarification. I will then re-write my code 
to have SQLFORM or SQLFORM.factory to later be able to inject html into the 
form. Really appreciate the help . I can now move forward!.

Regards,
Bhaskar


On Tuesday, December 25, 2012 9:43:52 AM UTC-6, Anthony wrote:


 But what about the DOM objects like radio buttons, text area etc in the 
 html ?. When the view file is processed and the response object is working 
 on it to generate pure HTML , won't it create a DOM tree structure in 
 memory. ?.


 No, if you just hand code the form HTML in the view but never create a 
 FORM or SQLFORM object, you don't get any server-side DOM. The server-side 
 DOM comes only with the use of the HTML helpers. If you want to take 
 advantage of the FORM DOM on the server but still want to customize your 
 HTML, check out http://web2py.com/books/default/chapter/29/07#Custom-forms
 .

 There are also other benefits of using FORM and SQLFORM in the controller 
 -- they automatically validate user inputs and return and display error 
 messages upon invalid input, and they add a special formkey token to the 
 form to prevent CSRF attacks and double form submission.

 Anthony 


-- 





Re: [web2py] Problem with routing

2012-12-25 Thread Jonathan Lundell
On 25 Dec 2012, at 7:58 AM, elyase yaser.marti...@gmail.com wrote:
 I have two controllers 'default.py' and 'error.py'. In my website 
 www.cubadena.com, if I try to access www.cubadena.com/default it correctly 
 redirects to the index() function inside the default controller, but if I do 
 the same with www.cubadena.com/error/ I get a: 
 
 Not Found
 
 The requested URL /error/ was not found on this server.
 
 Looking at the server logs I see a Attempt to serve directory: 
 /var/www/error/ error. How is this possible? I have both controller files 
 inside the web2py controller folder, and corresponding index.html files 
 inside a 'default' and 'error' folders in the application views folder. 
 Another curious thing is that if I add the application name to the URL it 
 works as expected for example:www.cubadena.com/cubadena/error (works!!)
 
 This is how my web2py routes.py looks like:
 
 routers = dict(
 BASE=dict(default_application='cubadena'),
 cubadena=dict(languages=['en', 'es'], default_language='es'),
 )
 
 routes_onerror = [(r'*/*', r'/cubadena/error/index')]
 
 What can I do to correct this behaviour?
 
 

This looks more like a server configuration problem than a routing problem. For 
some reason your server isn't sending the /error request to web2py at all, but 
rather trying to serve it from the file system.

-- 





Re: [web2py] Re: Graph Model (proposal to contribute)

2012-12-25 Thread Alan Etkin
 On Tuesday, December 25, 2012 12:45:31 PM UTC-3, Jose wrote:
El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro 
escribió:

 Not yet. It is the queue.


If you are using mercurial trunk with Linux try:

web2py path]$ touch NEWINSTALL

And restart web2py. I think this is required for updating the welcome 
installer.

I tried the graph action but complains about pygraphviz library not found

-- 





[web2py] Re: Merry Christmas everybody!

2012-12-25 Thread Gerd
Frohe Weihnachten und ein gutes neues Jahr!

Am Montag, 24. Dezember 2012 19:22:00 UTC+1 schrieb Massimo Di Pierro:

 Merry Christmas everybody!


-- 





[web2py] Re: Unable to load module mod_wsgi on Windows

2012-12-25 Thread at
Thanks for the help

I've tried the same module with apache 2.2 and it's working now. Downloaded 
mod_wsgi from here http://code.google.com/p/modwsgi/

Regards

On Monday, 24 December 2012 22:49:18 UTC+5, Paolo Caruccio wrote:

 If you plan to use mod_wsgi 3.4 in apache 2.4 on windows download newest 
 build from http://www.lfd.uci.edu/~gohlke/pythonlibs/ (search in the page 
 for mod_wsgi)

 If you are interested you could read also
  
 https://groups.google.com/d/topic/modwsgi/6nmiDUt0ldI/discussionhttps://groups.google.com/d/topic/modwsgi/6nmiDUt0ldI/discussion




 Il giorno lunedì 24 dicembre 2012 12:21:45 UTC+1, at ha scritto:


 After adding mod_wsgi in apache2, I am getting following error on apache 
 startup:
 httpd.exe: Syntax error on line 174 of 
 D:/wamp/bin/apache/apache2.4.2/conf/httpd.conf: Cannot load 
 D:/wamp/bin/apache/apache2.4.2/modules/mod_wsgi_win32.so into  server: %1 
 is not a valid Win32 application.

 The module was downloaded from 
 http://code.google.com/p/modwsgi/downloads/list

 Can somebody assist?

 Thanks  Regards
 AT



-- 





[web2py] Re: How to set/reset administrator password (apache+wsgi+windows)

2012-12-25 Thread Massimo Di Pierro
http://web2py.com/books/default/chapter/29/13#Setting-password

On Tuesday, 25 December 2012 08:25:38 UTC-6, at wrote:


 Hi

 After setting up web2py+apache with wsgi on windows, I can see web2py 
 admin page at http://localhost/admin/default/index. But it is asking 
 password to log into the administrative interface. How to set a password? 
 Is there any default password for first time entrance?

 Thanks
 AT




-- 





[web2py] Re: How to set/reset administrator password (apache+wsgi+windows)

2012-12-25 Thread Paolo Caruccio
My simple way:

a) stop apache server
b) start web2py server in standard way by double clicking web2py.py in 
order that it creates its own files
c) in displayed window set the admin password
d) stop web2py server and check that in web2py folder there 
are options_std.py and parameters_8000.py 
e) open options_std.py and make sure of row password = 'recycle' is 
present
f) restart apache server 

Now you sholuld be able to access to admin interface.

If you are interested omi chiba has written a guide to setup a wamp server 
that supports web2py through mod_wsgi.


Il giorno martedì 25 dicembre 2012 15:25:38 UTC+1, at ha scritto:


 Hi

 After setting up web2py+apache with wsgi on windows, I can see web2py 
 admin page at http://localhost/admin/default/index. But it is asking 
 password to log into the administrative interface. How to set a password? 
 Is there any default password for first time entrance?

 Thanks
 AT




-- 





[web2py] Re: How to set/reset administrator password (apache+wsgi+windows)

2012-12-25 Thread Paolo Caruccio


Il giorno martedì 25 dicembre 2012 19:41:17 UTC+1, Paolo Caruccio ha 
scritto:

 My simple way:

 a) stop apache server
 b) start web2py server in standard way by double clicking web2py.py in 
 order that it creates its own files
 c) in displayed window set the admin password
 d) stop web2py server and check that in web2py folder there 
 are options_std.py and parameters_8000.py 
 e) open options_std.py and make sure of row password = 'recycle' is 
 present
 f) restart apache server 

 Now you sholuld be able to access to admin interface.

 If you are interested omi chiba has written a 
 guidehttp://ochiba77.blogspot.it/2011/10/how-to-setup-web2py-apache-wsgi.htmlto
  setup a wamp server that supports web2py through mod_wsgi.


 Il giorno martedì 25 dicembre 2012 15:25:38 UTC+1, at ha scritto:


 Hi

 After setting up web2py+apache with wsgi on windows, I can see web2py 
 admin page at http://localhost/admin/default/index. But it is asking 
 password to log into the administrative interface. How to set a password? 
 Is there any default password for first time entrance?

 Thanks
 AT




-- 





[web2py] Re: Merry Christmas everybody!

2012-12-25 Thread Kostas M

+1

-- 





Re: [web2py] Re: Graph Model (proposal to contribute)

2012-12-25 Thread Alan Etkin
El martes, 25 de diciembre de 2012 12:45:31 UTC-3, Jose escribió:


 El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro 
 escribió:

 Not yet. It is the queue.


I've moved the table style to web2py.css and changed the xml generation 
with helpers to cleanup appadmin. Attached are the proposed diffs for 
appadmin.py and web2py.css.

Does this feature anything else but model visualization (so far)?. I mean, 
can I manage table definitions with clic and drag, etc?

-- 



diff -r ae21c7198a55 applications/welcome/static/css/web2py.css
--- a/applications/welcome/static/css/web2py.css	Mon Dec 24 16:14:04 2012 -0600
+++ b/applications/welcome/static/css/web2py.css	Tue Dec 25 16:26:51 2012 -0300
@@ -312,3 +312,34 @@
 .ie-lte8 div.flash{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#22', endColorstr='#00', GradientType=0 ); }
 .ie-lte8 div.flash:hover {filter:alpha(opacity=25);}
 .ie9 #w2p_query_panel {padding-bottom:2px}
+
+
+/* appadmin graph model */
+
+table.graph.model{
+  font: Helvetica Bold;
+  background-color: #F1F2AD;
+  border: 0.5em;
+}
+
+table.graph.model tbody{
+  color: #7B7B7B;
+  text-align: center;
+  padding: 0.5em;
+}
+
+table.graph.model td.left, table.graph.model td.center{
+  text-align: left;
+}
+
+table.graph.model td.right{
+  text-align: center;
+}
+
+table.graph.model thead{
+  color: white;
+  text-align: center;
+  padding: 0.5em;
+  background-color:#FFA21F;
+}
+
diff -r ae21c7198a55 applications/welcome/controllers/appadmin.py
--- a/applications/welcome/controllers/appadmin.py	Mon Dec 24 16:14:04 2012 -0600
+++ b/applications/welcome/controllers/appadmin.py	Tue Dec 25 16:25:48 2012 -0300
@@ -481,13 +481,14 @@
 return B('fk')
 else:
 return ' '
-# this is horribe HTML but the only one graphiz understands
-header = 'TRTD COLSPAN=3 CELLPADDING=4 ALIGN=CENTER BGCOLOR=#F\
-FA21FFONT FACE=Helvetica Bold COLOR=white%s/FONT/TD/TR' % table
-fields = []
+
+# This is horribe HTML but the only one graphiz understands
+header = TR(TD(FONT(table), _colspan=3))
 for field in db[table]:
-fields.append('TRTD ALIGN=LEFT CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica Bold%s/FONT/TDTD ALIGN=LEFT CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica%s/FONT/TDTD ALIGN=CENTER CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica%s/FONT/TD/TR' % (field.name,field.type,types(field)))
-return ' TABLE BGCOLOR=#F1F2AD BORDER=1 CELLBORDER=0 CELLSPACING=0%s %s/TABLE ' % (header, ' '.join(fields))
+fields.append(TR(TD(FONT(field.name), _class=left),
+ TD(FONT(field.type), _class=center),
+ TD(FONT(types(field)), _class=right)))
+return TABLE(THEAD(header), TBODY(*fields), _class=graph model)
 
 def bg_graph_model():
 graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')


Re: [web2py] Re: Graph Model (proposal to contribute)

2012-12-25 Thread Alan Etkin


 I've moved the table style to web2py.css and changed the xml generation 
 with helpers to cleanup appadmin. Attached are the proposed diffs for 
 appadmin.py and web2py.css.


Oops! That would never work (sorry, I didn't know the library requires 
special html input). This new patch instead uses helpers for creating the 
model image. Forget about the css diff (it's useless).

-- 



diff -r ae21c7198a55 applications/welcome/controllers/appadmin.py
--- a/applications/welcome/controllers/appadmin.py	Mon Dec 24 16:14:04 2012 -0600
+++ b/applications/welcome/controllers/appadmin.py	Tue Dec 25 17:38:13 2012 -0300
@@ -10,6 +10,7 @@
 import copy
 import gluon.contenttype
 import gluon.fileutils
+
 try:
 import pygraphviz as pgv
 except ImportError:
@@ -466,8 +467,10 @@
 ram=ram, disk=disk, object_stats=hp != False)
 
 
-
 def table_template(table):
+from gluon.html import TR, TD, TABLE, TAG
+def FONT(*args, **kwargs):
+return TAG.font(*args, **kwargs)
 def types(field):
 f_type = field.type
 if not isinstance(f_type,str):
@@ -481,13 +484,31 @@
 return B('fk')
 else:
 return ' '
-# this is horribe HTML but the only one graphiz understands
-header = 'TRTD COLSPAN=3 CELLPADDING=4 ALIGN=CENTER BGCOLOR=#F\
-FA21FFONT FACE=Helvetica Bold COLOR=white%s/FONT/TD/TR' % table
-fields = []
-for field in db[table]:
-fields.append('TRTD ALIGN=LEFT CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica Bold%s/FONT/TDTD ALIGN=LEFT CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica%s/FONT/TDTD ALIGN=CENTER CELLPADDING=4 BORDER=0FONT COLOR=#7B7B7B FACE=Helvetica%s/FONT/TD/TR' % (field.name,field.type,types(field)))
-return ' TABLE BGCOLOR=#F1F2AD BORDER=1 CELLBORDER=0 CELLSPACING=0%s %s/TABLE ' % (header, ' '.join(fields))
+
+# This is horribe HTML but the only one graphiz understands
+rows = []
+cellpadding = 4
+color = #7B7B7B
+bgcolor = #F1F2AD
+face = Helvetica Bold
+border = 0
+
+rows.append(TR(TD(FONT(table, _face=face, _color=white),
+   _colspan=3, _cellpadding=cellpadding,
+   _align=center, _bgcolor=#FFA21F)))
+for row in db[table]:
+rows.append(TR(TD(FONT(row.name, _color=color, _face=face),
+  _align=left, _cellpadding=cellpadding,
+  _border=border),
+   TD(FONT(row.type, _color=color, _face=face),
+   _align=left, _cellpadding=cellpadding,
+   _border=border),
+   TD(FONT(types(row), _color=color, _face=face),
+   _align=center, _cellpadding=cellpadding,
+   _border=border)))
+return  %s  % TABLE(*rows, _bgcolor=bgcolor, _border=1,
+_cellborder=0, _cellspacing=0).xml()
+
 
 def bg_graph_model():
 graph = pgv.AGraph(layout='dot', directed=True, strict=False, rankdir='LR')


Re: [web2py] Re: Graph Model (proposal to contribute)

2012-12-25 Thread Jose


El martes, 25 de diciembre de 2012 14:21:00 UTC-3, Alan Etkin escribió:

  On Tuesday, December 25, 2012 12:45:31 PM UTC-3, Jose wrote:
 El miércoles, 19 de diciembre de 2012 19:50:53 UTC-3, Massimo Di Pierro 
 escribió:

 Not yet. It is the queue.


 If you are using mercurial trunk with Linux try:

 web2py path]$ touch NEWINSTALL

 And restart web2py. I think this is required for updating the welcome 
 installer.


work, thanks .

Jose

-- 





[web2py] Re: Custom form delete Crud checkbox

2012-12-25 Thread Alan Etkin
El lunes, 24 de diciembre de 2012 19:09:30 UTC-3, Massimo Di Pierro 
escribió:

 I just added this to the web2py book in trunk. Will push it tomorrow.


Since the name in the default form is delete_this_record, shouldn't this 
be found in form.custom.delete_this_record also?

-- 





[web2py] Re: Custom form delete Crud checkbox

2012-12-25 Thread Alan Etkin
 Since the name in the default form is delete_this_record, shouldn't 
this be found in form.custom.delete_this_record also?

In case it should, here is a patch for allowing queries to the deletable 
widget by it's form name

-- 



diff -r 13d7e5ff851d gluon/sqlhtml.py
--- a/gluon/sqlhtml.py	Tue Dec 25 12:21:08 2012 -0600
+++ b/gluon/sqlhtml.py	Tue Dec 25 19:38:32 2012 -0300
@@ -235,7 +235,6 @@
 raise SyntaxError(
 'widget cannot determine options of %s' % field)
 opts = [OPTION(v, _value=k) for (k, v) in options]
-
 return SELECT(*opts, **attr)
 
 
@@ -1154,7 +1153,8 @@
  _id=self.FIELDKEY_DELETE_RECORD + SQLFORM.ID_LABEL_SUFFIX),
  widget,
  col3.get(self.FIELDKEY_DELETE_RECORD, '')))
-self.custom.deletable = widget
+self.custom.deletable = \
+self.custom[self.FIELDNAME_REQUEST_DELETE] = widget
 
 # when writable, add submit button
 self.custom.submit = ''


[web2py] upload field without the upload

2012-12-25 Thread lucas
hello one and all,

i am doing en masse data table using xml data to a table that has an upload 
field.  the files are already present in the upload subdirectory but i need 
to populate the table with the data, including the file name that is the 
upload field.  i hope that made sense.

how do i populate the fields using a db.table_name.insert(*...***) without 
web2py wanting to actually upload the file?

thanx in advance, lucas

-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread Bruno Cezar Rocha

AFAIK upload fields are just string fields, so you can insert any string there!

db.table.insert(filefield=blah)

should work!

You just have to use Python glob, os, sh or shutil to take a list of files and 
then populate the database.

On Tue, Dec 25, 2012 at 03:40:51PM -0800, lucas wrote:

hello one and all,

i am doing en masse data table using xml data to a table that has an upload
field.  the files are already present in the upload subdirectory but i need
to populate the table with the data, including the file name that is the
upload field.  i hope that made sense.

how do i populate the fields using a db.table_name.insert(*...***) without
web2py wanting to actually upload the file?

thanx in advance, lucas

--





--





[web2py] Re: Custom form delete Crud checkbox

2012-12-25 Thread Massimo Di Pierro
I am not convinced. 

It is in 

form.custom.delete

why does it need to be also in

form.custom.delete_this_record

Perhaps in web3py we can rename it but why have it in two places in web2py?

contains things which are not fields. The 

On Tuesday, 25 December 2012 16:43:47 UTC-6, Alan Etkin wrote:

  Since the name in the default form is delete_this_record, shouldn't 
 this be found in form.custom.delete_this_record also?

 In case it should, here is a patch for allowing queries to the deletable 
 widget by it's form name



-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread Massimo Di Pierro
You can do it and it will work. But you will not be able to download it 
using the download action. That is because it expects a certain format 
for filenames. You will need a custom download action that would know how 
to located the file from its name.

Massimo

On Tuesday, 25 December 2012 18:56:07 UTC-6, rochacbruno wrote:

 AFAIK upload fields are just string fields, so you can insert any string 
 there! 

 db.table.insert(filefield=blah) 

 should work! 

 You just have to use Python glob, os, sh or shutil to take a list of files 
 and then populate the database. 

 On Tue, Dec 25, 2012 at 03:40:51PM -0800, lucas wrote: 
 hello one and all, 
  
 i am doing en masse data table using xml data to a table that has an 
 upload 
 field.  the files are already present in the upload subdirectory but i 
 need 
 to populate the table with the data, including the file name that is the 
 upload field.  i hope that made sense. 
  
 how do i populate the fields using a db.table_name.insert(*...***) 
 without 
 web2py wanting to actually upload the file? 
  
 thanx in advance, lucas 
  
 -- 
  
  
  


-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread lucas
well, i get this error

Traceback (most recent call last):
  File /opt/web-apps/web2py/gluon/restricted.py, line 212, in restricted
exec ccode in environment
  File /opt/web-apps/web2py/applications/iquanta/controllers/site.py 
https://192.168.0.8/admin/default/edit/iquanta/controllers/site.py, line 489, 
in module
  File /opt/web-apps/web2py/gluon/globals.py, line 193, in lambda
self._caller = lambda f: f()
  File /opt/web-apps/web2py/applications/iquanta/controllers/site.py 
https://192.168.0.8/admin/default/edit/iquanta/controllers/site.py, line 484, 
in site_xml_files_import
id = tFls.insert(input_date=inputDate, modified_date=modDate, 
permission=permission, name=fname, ext=fext, type=ftype, description=fdsc, 
file=ffile)
  File /opt/web-apps/web2py/gluon/dal.py, line 7916, in insert
self._attempt_upload(fields)
  File /opt/web-apps/web2py/gluon/dal.py, line 7909, in _attempt_upload
raise RuntimeError(Unable to handle upload)
RuntimeError: Unable to handle upload

where line 484 in site.py is

id = db.files.insert(input_date=inputDate, modified_date=modDate, 
permission=permission, name=fname, ext=fext, type=ftype, description=fdsc, 
file=ffile)

where file is the upload field and i am passing it a string, most of which look 
something like

files.file.8710083b15af8a66.5044505f4c756b6163735f4e6f6973652d52656a656374696f6e5f525349312e706466.pdf

so what am i doing wrong?  lucas




-- 





Re: [web2py] images (uploaded files) not showing correctly after update?

2012-12-25 Thread Massimo Di Pierro
Was this ever fixed. Can you help me check?

On Sunday, 2 October 2011 17:42:39 UTC-5, Carlos wrote:

 Hi,

 I solved this in my case (without a redirect) as follows:

 + wrap each upload widget html into a 'wrapper' div.

 + after the form accepts/process, find each of those wrapper elements and 
 replace their contents (old value) with a new call to the upload widget 
 using the new value.

 The above was necessary because upload widgets are generated during the 
 SQLFORM init process, and their html is not changed during the form 
 accepts/process, therefore not showing the latest correct data.

 I also included a condition: replace the upload contents only if 
 form.vars.eachuploadfield is not None, i.e. only for those upload fields 
 that actually changed.

 Anyways, the above is just in case anybody else has the same problem.

 Regards,

Carlos



-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread lucas
ok, what if i just upload the file?  how do i do that programmically?  lucas

-- 





Re: [web2py] upload field without the upload

2012-12-25 Thread Massimo Di Pierro
https://groups.google.com/forum/?fromgroups=#!searchin/web2py/upload/web2py/CWNwcgo3wIU/1K_7wJBPh-0J

On Tuesday, 25 December 2012 20:51:21 UTC-6, lucas wrote:

 ok, what if i just upload the file?  how do i do that programmically?  
 lucas


-- 





[web2py] Re: The book updates and status

2012-12-25 Thread Massimo Di Pierro
So should we go with Serif or Sans Serif? To me Serif seems more 
professional. Any kindle book I have is Serif. Street sign and google group 
posts are Sans Serif (Helvetica).

massimo

On Saturday, 22 December 2012 17:59:43 UTC-6, Alan Etkin wrote:

  The font used on the online version is much more 'friendly', and 
 computer  oriented. Versus the printed font, which reminds me 
  formal law letters...

 I'm not sure about the better computer orientedness of the online version 
 over the roman font of the pdf. Also, Serif typography is said to be better 
 for long documents (I mean for long reading sessions).



--