[web2py] Re: How to play flv video files in web2py?

2012-06-21 Thread TheSweetlink
Perhaps you can store the encoded filename in the db rather than the 
original or add a new field to store newly encoded filename?

video-js helped make playing vids easier.

Best of luck,
David

On Tuesday, June 12, 2012 6:04:21 AM UTC-4, Charles Tang wrote:

 I am using web2py to play user's uploaded video file encoding with 
 different encoding params.Only the original uploaded video is in db and it 
 can be accessed and played using code below:
 script type=text/javascript
 var flashvars = {};
 flashvars.myurl = {{=URL('download', 
 args=video.file)}}; 
 flashvars.width = {{=video.width}};
 flashvars.height = {{=video.height}};
 flashvars.widthshift = {{=video.widthshift}};
 flashvars.method =  {{=video.method}}; 
 
 var params = {};
 params.play = false;
 params.loop = false;
 params.menu = false;
 params.quality = best;
 params.scale = showall;
 params.wmode = window;
 params.swliveconnect = true;
 params.allowfullscreen = true;
 params.allowscriptaccess = always;
 params.allownetworking = all;
 var attributes = {};
 attributes.id = container;
 
 swfobject.embedSWF({{=URL(c='static',f='videoPlayer/videoPlay.swf')}},myAlternativeContent,
   
 {{=video.width}}, {{=video.height}}, 9.0.0, false, flashvars, params, 
 attributes);
 /script 

 div id=myAlternativeContent
 a href=http://www.adobe.com/go/getflashplayer;
 img src=
 http://www.adobe.com/images/shared/download_buttons/
 get_flash_player.gif alt=Get Adobe Flash player 
 /
 /a
 /div 


 In the code flashvars.myurl = {{=URL('download', args=video.file)}};  
 the controller download is below:
 def download():
 return response.download(request,  db)

 It works to play the uploaded video.The problem is the converted video 
 files using ffmpeg with other params is not in db, so I can't access these 
 videos via response.download. 
 I tried two methods: 
 1.Set flashvars.file={{=URL(r=request,c='static',f='test.flv')}},but the 
 flash player didn't play the video but the browser automatically popup a 
 file download window.
 2.Set flashvars.myurl={{=URL('show_video')}}
in controller:
def show_video():
response.headers['Content-Type'] = application/octet-stream
response.headers['Content-Disposition'] = 'filename=test.flv'
return 
 response.stream(open('/data/python_website/web2py/applications/encodeupload/uploads/test.flv','rb'),chunk_size=4096)
   It still popup a download window rather than play it.
 Neither of them works. So how to play a video file without 
 response.download?



-- 





[web2py] Re: Current status of adapting OrientDB for web2py

2012-02-16 Thread TheSweetlink
Hello all,

I do not have a patch as it is not for the DAL however I can show you
this handy module I hacked up.

It will add/remove edges to an OrientDB document-graph DB as well as
return the RID of a newly inserted record.

CRUD for now is project dependant on what if any schema you have
implemented in Orient and so not included.

It could use some try, except...to ensure that the transaction
completed but I did not include that as the test for successful insert
will likely rely on your schema if you have one.

NOTE: This is older code that was quickly abstracted from a project to
protect certain parts of code.  I'm certain there are several
abstractions/optimizations/fixes that can be applied to this code.
I'll leave it to you to please 2x check and tweak it to fit your
specific project.

The reason for lopping off the first character in some parts is
because RID's are actually strings that begin with a '#'.  Please see
http://code.google.com/p/orient/wiki/Concepts#Record and the rest of
the wiki for more details.  It is a good read.

@David Marko, I cannot build a whole application as that will take
some time to build an OrientDB instance which would exemplify all the
things you can do.

When I have more free time I may build an appliance because I want
more exposure to both projects.

I can certainly point you in the right direction though and once you
read the wiki everything will make much more sense.


Libs used:

re - to get RID from an INSERTed record
requests - http for humans...GREAT library,
ujson as json - fast moving of JSON data between OrientDB -- web2py,


Behold!  A simple module to add/remove in/out edges with OrientDB's
document-graph db as well as retrieving the RID of a newly inserted
record.  May it help you and many more.
http://paste.pocoo.org/show/552147/


-David Bloom


On Feb 16, 12:03 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 You say you have been using it. Do you have a patch? I'll be happy to
 take a look and include it.

 On Feb 15, 2:48 pm, TheSweetlink yanosh...@gmail.com wrote:







  Hello,

  I have been using OrientDB and web2py quite successfully for some
  months now.

  While there are many great projects and efforts to combine these
  powerful programs, I do not know of the current status of the web2py
  --- OrientDB adapter.

  Bulbflow is a great project too but I could not use it due to OrientDB
  specific features that I needed for my project.

  Neo4j has had great progress as well.

  I ultimately chose OrientDB for several reasons which made it the best
  fit for my projects.  Here are some of those highlights:

  1) multi-master (as far as I know you must pay for commercial license
  to get multi-master in Neo4j)

  2) the Apache 2.0 license is very liberal.

  3) Luca and the OrientDB community are as turbo fast and helpful as
  the web2py community.  Luca can get patches out in hours to days, not
  months to years.

  4) SQL syntax + Gremlin graph traversal language = untold power to
  grow/analyze your graph dbs.

  5) Much more...for details see orienttechnologies.com and click Learn
  More.  Do read the entire wiki as there is good documentation and
  more coming frequently.

  As for getting OrientDB to work with web2py, I have had to write
  custom modules to do basic CRUD and used OrientDB's built-in console
  to create my schema/maintain the DB.

  I've experienced great success with using requests and ujson python
  libs to move data back and forth from web2py -- OrientDB

  For Auth I still use a db which will work with web2py's amazing DAL.
  I'm sure with enough time you could hack the two to work together but
  I prefer to use something proven for auth until such time OrientDB is
  included in the DAL.

  Massimo has expressed interest in including OrientDB within the DAL
  but I would assume that this will take quite some time as he has much
  higher priorities for web2py to get to first.

  I highly recommend the combination of web2py and OrientDB.  It will
  take some customization, but once running you will be able to do
  things that web2py + traditional RDBMS simply cannot do.

  Some of my apps have experienced 10-100x performance boost due to no
  longer using JOINS to get data but rather traversing my graph.

  Best of luck,
  David

  On Feb 13, 12:54 pm, Nolan Nichols nolan.nich...@gmail.com wrote:

   I'm researching the nosql and graph database landscape for a web2py
   application that will require the schema to evolve over time and
   provide network/graph analysis metrics.

   I started by looking at the Tinkerpop (http://tinkerpop.com/) stack
   and the Bulbflow (http://bulbflow.com/) python library for interacting
   with Tinkerpop graph databases like Neo4j and OrientDB.

   It looks like there was interest a few months back in adapting
   OrientDB's sql interface for web2py, and there is an open issue:

   -http://code.google.com/p/web2py/issues/detail?id=407

   A few questions:

   What is the current

[web2py] Re: Current status of adapting OrientDB for web2py

2012-02-15 Thread TheSweetlink
Hello,

I have been using OrientDB and web2py quite successfully for some
months now.

While there are many great projects and efforts to combine these
powerful programs, I do not know of the current status of the web2py
--- OrientDB adapter.

Bulbflow is a great project too but I could not use it due to OrientDB
specific features that I needed for my project.

Neo4j has had great progress as well.

I ultimately chose OrientDB for several reasons which made it the best
fit for my projects.  Here are some of those highlights:

1) multi-master (as far as I know you must pay for commercial license
to get multi-master in Neo4j)

2) the Apache 2.0 license is very liberal.

3) Luca and the OrientDB community are as turbo fast and helpful as
the web2py community.  Luca can get patches out in hours to days, not
months to years.

4) SQL syntax + Gremlin graph traversal language = untold power to
grow/analyze your graph dbs.

5) Much more...for details see orienttechnologies.com and click Learn
More.  Do read the entire wiki as there is good documentation and
more coming frequently.


As for getting OrientDB to work with web2py, I have had to write
custom modules to do basic CRUD and used OrientDB's built-in console
to create my schema/maintain the DB.

I've experienced great success with using requests and ujson python
libs to move data back and forth from web2py -- OrientDB

For Auth I still use a db which will work with web2py's amazing DAL.
I'm sure with enough time you could hack the two to work together but
I prefer to use something proven for auth until such time OrientDB is
included in the DAL.

Massimo has expressed interest in including OrientDB within the DAL
but I would assume that this will take quite some time as he has much
higher priorities for web2py to get to first.

I highly recommend the combination of web2py and OrientDB.  It will
take some customization, but once running you will be able to do
things that web2py + traditional RDBMS simply cannot do.

Some of my apps have experienced 10-100x performance boost due to no
longer using JOINS to get data but rather traversing my graph.

Best of luck,
David

On Feb 13, 12:54 pm, Nolan Nichols nolan.nich...@gmail.com wrote:
 I'm researching the nosql and graph database landscape for a web2py
 application that will require the schema to evolve over time and
 provide network/graph analysis metrics.

 I started by looking at the Tinkerpop (http://tinkerpop.com/) stack
 and the Bulbflow (http://bulbflow.com/) python library for interacting
 with Tinkerpop graph databases like Neo4j and OrientDB.

 It looks like there was interest a few months back in adapting
 OrientDB's sql interface for web2py, and there is an open issue:

 -http://code.google.com/p/web2py/issues/detail?id=407

 A few questions:

 What is the current status of an OrientDB/web2py adapter?
 Is anyone currently using a graph database with web2py?
 Any suggestions for using web2py DAI/templates with non-rdbms sources?

 Cheers,

 Nolan


[web2py] Re: new web site

2011-11-07 Thread TheSweetlink
Good upgrade!

I particularly like the Bossie Award at the top, the detailed
web2py_vs_others.pdf (needs a few minor corrections noted below), and /
what but I don't understand why the link is titled 3rd party tools.

Slide notes:
Slides 36 and 40 say SQLField instead of Field like in the Book.

94 says allow allow

All in all I really liked the tactfully explained, as per usual,
comparisons.

Well done.

David

On Nov 6, 3:02 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 We have a new web site

    http://web2py.com/new_examples

 Please check it out before we replace the old one.


[web2py] Re: we need some good web2py quotes ....

2011-11-05 Thread TheSweetlink
web2py will inspire the beginner and empower the advanced to rapidly
develop robust web applications with Python.
Its international community is both helpful and responsive to
questions ranging from the most basic to the complicated and advanced.
If you value ease of use, security, and rapid development of web
applications all wrapped in a highly integrated package then I highly
recommend you give web2py a try.

David Bloom



On Nov 4, 7:08 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 more or less as long as this one:

 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla bla bla bla bla bla

 if it looks good but not cheesy we will use for the web2py.com site.


[web2py] Re: Confused about hidden fields

2011-11-03 Thread TheSweetlink
I am not certain that the case is the same but one thing I noticed
with SQLFORM.factory and hidden fields was that in order to pass a
hidden field from the SQLFORM.factory(...hidden=dict(Sir Robin: 'the
brave')) required that a Field(...) be defined for it in the form
definition.

To make it hidden, just set readable=False, writable=False.  So what I
did was something like this:

SQLFORM.factory(Field(...), Field(...), Field('sirRobin',
readable=False, writable=False...),
hidden=dict(sirRobin: 'the brave')

This will create a hidden field that isn't shown or which you can
change and its value is passed in from the controller.

You're already using a custom form and that's important too as the
hidden field must be somewhere in your custom form so that it can
submit your hidden field along with the rest of the form.

I hope this is helpful to you Omi.

David

On Nov 1, 6:20 pm, Omi Chiba ochib...@gmail.com wrote:
 Sorry, I'm so confused and hard to explain but...

 I have a field which value was set from another table and don't want
 to show on the user. I just want to set default value in controller
 and submit the form with the fields user filled in.

 Do I need to include the field in the view but make it hidden ?

 or

 Use SQLFORM(, hidden=dict(FFTSCD='aaa'),

 below is a part of my view FFTSCD is the field I don't want to show.
 --
 {{extend 'layout.html'}}
 h1Fedex Request Form - {{=keyHJ}}/h1
 Report Date: {{=form.custom.widget.FFTRD}}
 {{=form.custom.begin}}
 table
 trtd colspan=2h3User Information/h3/tdtr
 trtdCreated by: /tdtd{{=form.custom.widget.FFCUSR}}/td/tr
 trtdCreated on: /tdtd{{=form.custom.widget.FFCDAT}}/td/tr

 trtd{{=form.custom.submit}}/td/tr
 /table
 {{=form.custom.widget.FFTSCD}}
 {{=form.custom.end}}


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-30 Thread TheSweetlink
How delightfully newbtastic of me.  I don't have it working quite the
way I want to yet but it does indeed appear that a global JS variable
will do the trick.

Thanks for the help Anthony.

David

On Oct 28, 6:52 pm, Anthony abasta...@gmail.com wrote:
 On Friday, October 28, 2011 6:50:20 PM UTC-4, TheSweetlink wrote:

  Do you mean something like use jQuery from the outer part of the page
  which contains the component?

  I do not know how I would do that.  I tried something along those
  lines unsuccessfully before but I may have just implemented it
  incorrectly.

  My trouble is having js interact with the stuff loaded into the
  component, from outside the component.

 Yes. The component is just a div in the page, so JS from outside the
 component should be able to interact with it. In fact, you can have one
 component interact with another (e.g., clicking a link in one component can
 trigger another to reload).

 Anthony


[web2py] How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
I have an app that polls for new messages and reloads a component when
there are new messages.

My problem is that when the component is refreshed/reloaded while a
user is typing, the message being typed disappears.

This makes sense because the component contains the form being
submitted.  For example refreshing the page before a form submission,
the refreshed page won't contain whatever was being typed.

I wish to retain the form data after the component is refreshed so
that the user can continue typing a message without having everything
blanked every time a new message appears.

What do you recommend as a method to keep what is being typed across a
component reload?

All I can think of right now is using web2py's ajax() to keep feeding
a session var whatever is being typed using JQuery's .change()

If there is anything in the session var, display it after the
component reload.  Upon form submission, clear the session var.

It just seems awfully inefficient to update a session var with the
ajax function for every character typed.

Can you suggest a smarter way of retaining the form's data after a
component reload?

Your help is most appreciated.

David


[web2py] Re: Manual Upload with FORM

2011-10-28 Thread TheSweetlink
Hello Ross,

Here is a bunch of info from another post I made regarding manual
uploads with SQLFORM.factory.

Now that I notice it though, you are using FORM and I'm uncertain
whether or not FORM worked for me, I had to use SQLFORM.

The whole thread can be found here for more info, relevant stuff
posted below:

http://groups.google.com/group/web2py/browse_thread/thread/fe03404c155aaf10/f9cb6c1ac67c3f49?lnk=gstq=thesweetlink#f9cb6c1ac67c3f49

Two things I've found when manually uploading via SQLFORM.factory:

1)  You need to specify a table_name='...' to avoid the
no_table_newfilename.extension issue like this:

form = SQLFORM.factory(...Field definitions...,
table_name='some_table_name')

2)  Additionally you must specify an uploadfolder in your upload Field
definition similar to this:

form = SQLFORM.factory(...,
Field('invoice_logo', type='upload',
uploadfolder=os.path.join(request.folder,'static/uploads/')),
..., table_name='whatever_you_like')

**NOTE** 'static/uploads' is just an example, you can upload to
wherever it will be appropriate.

In this case the newly uploaded and renamed file to
your_application's_dir/static/uploads/your_new_filename_here

One gotcha to look out for following your field name as an example
without the quotation marks:

In your form.accepts(...):

request.vars.invoice_logo will contain the original filename of your
upload whereas

form.vars.invoice_logo_newfilename will contain the newly renamed
file like yourtablename.9203842903.thaoeu09gu023hgda3p.ext

No need to call store() directly as SQLFORM.factory will take care of
that for you.

I hope that this helps you.

David

On Oct 28, 10:38 am, Ross Peoples ross.peop...@gmail.com wrote:
 Having a little trouble with getting an attachment to work. This is a
 simplified version of the controller:

 form = FORM('Attach', [INPUT(_name='attachment', _type='file')])

 if form.accepts(request):
     v = form.vars.attachment
     if not v is None and not v == '':
         v = db.attachments.attachment.store(v)

     db(db.attachments.id==id).update(attachment = v)

 And this is the result:

 Traceback (most recent call last):
   File /media/psf/Python/web2py/gluon/restricted.py, line 194, in restricted
     exec ccode in environment
   File /media/psf/Python/web2py/applications/marlin/controllers/default.py 
 https://172.16.100.111:8000/admin/edit/marlin/controllers/default.py, line 
 586, in module
   File /media/psf/Python/web2py/gluon/globals.py, line 149, in lambda
     self._caller = lambda f: f()
   File /media/psf/Python/web2py/applications/marlin/controllers/default.py 
 https://172.16.100.111:8000/admin/edit/marlin/controllers/default.py, line 
 471, in view_invite
     v = db.rfq_item[field].store(v)
   File /media/psf/Python/web2py/gluon/dal.py, line 5557, in store
     shutil.copyfileobj(file, dest_file)
   File /usr/lib/python2.6/shutil.py, line 27, in copyfileobj
     buf = fsrc.read(length)
   File /usr/lib/python2.6/cgi.py, line 522, in __getattr__
     raise AttributeError, name
 AttributeError: read

 The code for using store(v) came from another thread. When I print out v 
 before calling store(), it prints out something like this:

 FieldStorage('attachment', 'filename.txt', 'The actual text of the file')

 Looking through the dal.py, it looks like the line shutil.copyfileobj(file, 
 dest_file) is expecting an actual File object, not a FieldStorage object, 
 hence the attribute error. But if I try to pass storage(v.file) instead of 
 storage(v), then the DAL errors out because it's expecting a FieldStorage 
 object, not a File object.

 Is this a bug or am I doing something wrong here? I should mention that using 
 SQLFORM and SQLFORM.factory with attachments works just fine, it's only FORM 
 that is giving me trouble.


[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
Hi Anthony and thanks for your reply.

I do not believe that I can separate the form from the component.

Think of the component like a message board with a form up top for a
main post with comment forms for each post all wrapped into one
component.

All of the forms get blanked upon component reload as that's their
original state.

Any post or comment being typed retains focus for the correct form,
but is blanked.

Even if I broke the component down to two (post and comment) comments
would get blanked upon component refresh showing new posts.

I will attempt my first idea of using web2py's ajax() and a session
var and test the performance as it may not be so horrible but I would
prefer to have a more efficient method if possible.

Do you have any other tricks to try?

David

On Oct 28, 3:48 pm, Anthony abasta...@gmail.com wrote:
 Can you separate the form being typed in from the data being displayed by
 the refresh (i.e., maybe used two separate components)?

 On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote:

  I have an app that polls for new messages and reloads a component when
  there are new messages.

  My problem is that when the component is refreshed/reloaded while a
  user is typing, the message being typed disappears.

  This makes sense because the component contains the form being
  submitted.  For example refreshing the page before a form submission,
  the refreshed page won't contain whatever was being typed.

  I wish to retain the form data after the component is refreshed so
  that the user can continue typing a message without having everything
  blanked every time a new message appears.

  What do you recommend as a method to keep what is being typed across a
  component reload?

  All I can think of right now is using web2py's ajax() to keep feeding
  a session var whatever is being typed using JQuery's .change()

  If there is anything in the session var, display it after the
  component reload.  Upon form submission, clear the session var.

  It just seems awfully inefficient to update a session var with the
  ajax function for every character typed.

  Can you suggest a smarter way of retaining the form's data after a
  component reload?

  Your help is most appreciated.

  David




[web2py] Re: How can I retain form data across a web2py_component() refresh?

2011-10-28 Thread TheSweetlink
Do you mean something like use jQuery from the outer part of the page
which contains the component?

I do not know how I would do that.  I tried something along those
lines unsuccessfully before but I may have just implemented it
incorrectly.

My trouble is having js interact with the stuff loaded into the
component, from outside the component.

What you say makes sense though, I'll play around with that.

Thank you for you suggestions Anthony.

On Oct 28, 6:40 pm, Anthony abasta...@gmail.com wrote:
 Since the whole page isn't reloading, can't you capture what is being typed
 using Javascript and then fill the content back in once the component
 refreshes (i.e., do everything client side)?

 On Friday, October 28, 2011 5:56:54 PM UTC-4, TheSweetlink wrote:

  Hi Anthony and thanks for your reply.

  I do not believe that I can separate the form from the component.

  Think of the component like a message board with a form up top for a
  main post with comment forms for each post all wrapped into one
  component.

  All of the forms get blanked upon component reload as that's their
  original state.

  Any post or comment being typed retains focus for the correct form,
  but is blanked.

  Even if I broke the component down to two (post and comment) comments
  would get blanked upon component refresh showing new posts.

  I will attempt my first idea of using web2py's ajax() and a session
  var and test the performance as it may not be so horrible but I would
  prefer to have a more efficient method if possible.

  Do you have any other tricks to try?

  David

  On Oct 28, 3:48 pm, Anthony abas...@gmail.com wrote:
   Can you separate the form being typed in from the data being displayed
  by
   the refresh (i.e., maybe used two separate components)?

   On Friday, October 28, 2011 3:16:41 PM UTC-4, TheSweetlink wrote:

I have an app that polls for new messages and reloads a component when
there are new messages.

My problem is that when the component is refreshed/reloaded while a
user is typing, the message being typed disappears.

This makes sense because the component contains the form being
submitted.  For example refreshing the page before a form submission,
the refreshed page won't contain whatever was being typed.

I wish to retain the form data after the component is refreshed so
that the user can continue typing a message without having everything
blanked every time a new message appears.

What do you recommend as a method to keep what is being typed across a
component reload?

All I can think of right now is using web2py's ajax() to keep feeding
a session var whatever is being typed using JQuery's .change()

If there is anything in the session var, display it after the
component reload.  Upon form submission, clear the session var.

It just seems awfully inefficient to update a session var with the
ajax function for every character typed.

Can you suggest a smarter way of retaining the form's data after a
component reload?

Your help is most appreciated.

David




[web2py] Re: using lambda for represent a field - what I misunderstood?

2011-10-27 Thread TheSweetlink
Is there a reason for using represent to make redirection links?  You
may have an easier time creating redirection links with the A()
helper:

http://web2py.com/book/default/chapter/05?search=redirect

Apparently there is a new callback feature to the A helper which might
be helpful in your situation.

I couldn't tell you what's wrong without seeing more code.

Wish I could help more but one of the gurus will have a better Why is
this so? than I.

David

On Oct 26, 1:40 pm, Lazarof lazaro...@gmail.com wrote:
 ## The code ...
 from gluon.contrib.populate import populate

 db.define_table('product',
     Field('field_n1'),
     Field('field_n2'))

 if db(db.product).isempty():
     populate(db.product, 17)

 some_function = 'function_n1'
 some_action = 'action_n1'
 some_table = 'table_n1'
 back_to = 'back_to_pt01'
 db.product.id.represent = lambda value,row: A('Ed',
 _href=URL(f=some_function, args=(some_action, some_table, back_to,
 value)))

 ## (1)
 ## when id=1 as a result I expect a link named Ed with href = '../app/
 default/function_n1/action_n1/table_n1/back_to_pt01/1'

 some_function = 'function_n2'
 some_action = 'action_n2'
 some_table = 'table_n2'
 back_to = 'back_to_pt02'
 db.product.field_n1.represent = lambda value,row: A(value,
 _href=URL(f=some_function, args=(some_action, some_table, back_to,
 row.id)))

 ## (2)
 ## when id=1 as a result I expect the content of field_n1 with href =
 '../app/default/function_n2/action_n2/table_n2/back_to_pt02/1'

 ## (3) and here is the question ...
 ## for both (1) and (2)
 ## I am geting href = '../app/default/function_n2/action_n2/table_n2/
 back_to_pt02/1'
 ## Is that correct?

 ## with this code I get what I am expecting
 ##xsome_function = 'function_n2'
 ##xsome_action = 'action_n2'
 ##xsome_table = 'table_n2'
 ##xback_to = 'back_to_pt02'
 ##db.product.field_n1.represent = lambda value,row: A(value,
 _href=URL(f=xsome_function, args=(xsome_action, xsome_table, xback_to,
 row.id)))

 Can someone switch on the light, please.
 Lazaro


[web2py] Re: Massimo Di Pierro talks about web2py on FLOSS Weekly

2011-10-27 Thread TheSweetlink
Very cool.  I especially enjoyed the tactful handling of web2py's
criticisms amongst the Python community as well as the fascinating
physics tangent.  M lattice quantum chromodynamics.

May this bring even more attention to web2py.

David

On Oct 26, 3:17 pm, Bruno Rocha rochacbr...@gmail.com wrote:
 Massimo Di Pierro talks about web2py on FLOSS Weekly

 AUDIO:http://twit.cachefly.net/floss0188.mp3

 VIDEO:http://twit.tv/show/floss-weekly/188

 --

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


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-24 Thread TheSweetlink
Thank you Massimo.

Because having it work isn't enough I have a question out of morbid
curiosity/desire to learn the framework better.

Why must the fieldnames match between the Field('fieldname'...)
definition and form.errors.fieldname in my validating function in
order to get form.errors.fieldname to flash a form error?

Thank you.

David



On Oct 24, 10:25 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Good solutions. Not everything can be done with built-in validators.

 On Oct 24, 12:13 am, TheSweetlink yanosh...@gmail.com wrote:

  Thank you all for your help.

  I was able to resolve the problem quirky as it may be but here we go.
  For science!!!

  To get a type='list:string' to fail validation if none passed from
  your SQLFORM.factory form:

  1) Used an onvalidation=... in my form.accepts(...) /
  process(...).accepted / validate(...)

  Within the validation function:

  if not request.vars.choochoo:
  form.errors.choochoo = Please select 1 or more witches before
  burning them.

  form.errors.fieldname --- Unless the fieldname
  matched .errors.fieldname, flashing form.errors.fieldname wouldn't
  work.

  To reiterate more simply, Field('choochoo'...) had to match
  form.errors.choochoo in order to have
  form = SQLFORM.factory(...)
  if form.validate(...):
  do something
  elif form.errors.choochoo:
  response.flash = form.errors.choochoo

  work when set from my onvalidation function

  2)  IS_NOT_EMPTY() constraint added after form = SQLFORM.factory(...)

  form.element('#no_table_myawesomeselect')
  ['requires']=IS_NOT_EMPTY(error_message='Please select 1 or more
  witches before burning them.')

  It wouldn't work when added to requires= in the Field(...) of my form
  = definition but only when added after form is created but before
  processing.

  Now my errors flash from response as they should according to the
  onvalidation function that's called.

  Thanks again web2py community, you're wonderful as always.

  David

  On Oct 23, 11:21 pm, ニコノコ nikolai...@gmail.com wrote:

   Eeugh. Sorry for the ugly suggestion. Post validation could

   def person_processing(form):

   if len(form.vars.field or '')1:
   form.errors.field= 'Select one.'

   On Oct 24, 10:32 am, Vasile Ermicioi elff...@gmail.com wrote:

 How about:  db.table.field.requires = IS_LENGTH(1)

that will limit the field to one character, not to one value from set




[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-24 Thread TheSweetlink
Cool, yes that is what I was asking about and thank you for the
answer.  It makes sense, just like the rest of the framework.

David

On Oct 24, 12:35 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 If I understand the question...
 Because otherwise SQLFORM would not know where to display the error.


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
I don't wish to irritate rather just curious to know if anyone else
can replicate this.

A SQLFORM.factory with an empty field of type='list:string' is
submitting as passed when an IS_NOT_EMPTY() validator is used in any
and every way possible.

The very same .factory has a field type string where the same exact
validation works as it should.  Why should my list:string not work the
same way?

Thank you in advance for your time.

David


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Thank you Massimo,

The expected behavior is for the 'list:string' field to be a required
field in order for the form to pass validation.

It is currently a jquery multi-select checkbox dropdown created from
an IS_IN_SET(...zero=None) validator on the same field (which works
perfectly to my knowledge).

I'm fairly certain there is a simple way to accomplish what I want to
do but I'm not seeing it.

The idea is to have a custom error message like 'Please select one or
more...bloggittyblahblah'.

I have a validator in the form which works great for an empty string,
sadly though my list:select will submit no matter what I do whether
there are options selected or none selected.

How can I implement something like IS_NOT_EMPTY() to require the field
have a value to pass validation with a 'list:string' field?

David

On Oct 23, 6:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Thanks for the reminder. What is the expected behavior? 'list:string'
 only accepts strings that are not empty. Are you trying to have at
 least one item in the list?
 We do not have a validator to do that but can make one:

 class IS_LIST_SIZE(Validator):

     def __init__(self, min=0,max=10,error_message='not in range'):
         self.min = min
         self.max=max
         self.error_message = error_message

     def __call__(self, value):
         ivalue = value
         if not isinstance(value, list):
             ivalue = [ivalue]
         if not self.min=len(ivalue)=self.max:
             return (ivalue, self.error_message)
         return (ivalue, None)

 On Oct 23, 5:37 pm, TheSweetlink yanosh...@gmail.com wrote:

  I don't wish to irritate rather just curious to know if anyone else
  can replicate this.

  A SQLFORM.factory with an empty field of type='list:string' is
  submitting as passed when an IS_NOT_EMPTY() validator is used in any
  and every way possible.

  The very same .factory has a field type string where the same exact
  validation works as it should.  Why should my list:string not work the
  same way?

  Thank you in advance for your time.

  David




[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Ugh, just realized, right from the online book:


Note that when multiple=True, IS_IN_SET will accept zero or more
values, i.e. it will accept the field when nothing has been selected.


How can I have multiple=true AND require the field?  Is that possible?

David


TheSweetlink wrote:
 Thank you Massimo,

 The expected behavior is for the 'list:string' field to be a required
 field in order for the form to pass validation.

 It is currently a jquery multi-select checkbox dropdown created from
 an IS_IN_SET(...zero=None) validator on the same field (which works
 perfectly to my knowledge).

 I'm fairly certain there is a simple way to accomplish what I want to
 do but I'm not seeing it.

 The idea is to have a custom error message like 'Please select one or
 more...bloggittyblahblah'.

 I have a validator in the form which works great for an empty string,
 sadly though my list:select will submit no matter what I do whether
 there are options selected or none selected.

 How can I implement something like IS_NOT_EMPTY() to require the field
 have a value to pass validation with a 'list:string' field?

 David

 On Oct 23, 6:58 pm, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:
  Thanks for the reminder. What is the expected behavior? 'list:string'
  only accepts strings that are not empty. Are you trying to have at
  least one item in the list?
  We do not have a validator to do that but can make one:
 
  class IS_LIST_SIZE(Validator):
 
      def __init__(self, min=0,max=10,error_message='not in range'):
          self.min = min
          self.max=max
          self.error_message = error_message
 
      def __call__(self, value):
          ivalue = value
          if not isinstance(value, list):
              ivalue = [ivalue]
          if not self.min=len(ivalue)=self.max:
              return (ivalue, self.error_message)
          return (ivalue, None)
 
  On Oct 23, 5:37 pm, TheSweetlink yanosh...@gmail.com wrote:
 
   I don't wish to irritate rather just curious to know if anyone else
   can replicate this.
 
   A SQLFORM.factory with an empty field of type='list:string' is
   submitting as passed when an IS_NOT_EMPTY() validator is used in any
   and every way possible.
 
   The very same .factory has a field type string where the same exact
   validation works as it should.  Why should my list:string not work the
   same way?
 
   Thank you in advance for your time.
 
   David
 
 


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Hello Vasile,

I tried that and the IS_NOT_EMPTY() doesn't take.

I should really test if the IS_IN_SET() is working properly too but I
suspect that it is.

I need to find out how I can override that behavior I described above
from the book.

Apparently multiple=true allows IS_IN_SET() to pass validation even
without that var being sent along with the rest.

Thanks for your help all.

David

On Oct 23, 9:32 pm, Vasile Ermicioi elff...@gmail.com wrote:
 perhaps

 db.table.field.requires = [IS_NOT_EMPTY(), IS_IN_SET(...)]


[web2py] Re: SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-23 Thread TheSweetlink
Thank you all for your help.

I was able to resolve the problem quirky as it may be but here we go.
For science!!!

To get a type='list:string' to fail validation if none passed from
your SQLFORM.factory form:

1) Used an onvalidation=... in my form.accepts(...) /
process(...).accepted / validate(...)

Within the validation function:

if not request.vars.choochoo:
form.errors.choochoo = Please select 1 or more witches before
burning them.

form.errors.fieldname --- Unless the fieldname
matched .errors.fieldname, flashing form.errors.fieldname wouldn't
work.

To reiterate more simply, Field('choochoo'...) had to match
form.errors.choochoo in order to have
form = SQLFORM.factory(...)
if form.validate(...):
do something
elif form.errors.choochoo:
response.flash = form.errors.choochoo

work when set from my onvalidation function


2)  IS_NOT_EMPTY() constraint added after form = SQLFORM.factory(...)

form.element('#no_table_myawesomeselect')
['requires']=IS_NOT_EMPTY(error_message='Please select 1 or more
witches before burning them.')

It wouldn't work when added to requires= in the Field(...) of my form
= definition but only when added after form is created but before
processing.



Now my errors flash from response as they should according to the
onvalidation function that's called.

Thanks again web2py community, you're wonderful as always.

David





On Oct 23, 11:21 pm, ニコノコ nikolai...@gmail.com wrote:
 Eeugh. Sorry for the ugly suggestion. Post validation could

 def person_processing(form):

 if len(form.vars.field or '')1:
 form.errors.field= 'Select one.'

 On Oct 24, 10:32 am, Vasile Ermicioi elff...@gmail.com wrote:

   How about:  db.table.field.requires = IS_LENGTH(1)

  that will limit the field to one character, not to one value from set




[web2py] SQLFORM.factory not respecting IS_NOT_EMPTY() for list:string?

2011-10-21 Thread TheSweetlink
I have a SQLFORM.factory that is respecting IS_NOT_EMPTY() for a field
with type='string' but not respecting it for a diffirent field of
type='list:string'.

If the list:string type field is left empty the form validates.

Confirmed with firebug.

Tested with form.accepts, form.process(...).accepted, and
form.validate.

I tried removing all other conditions in the list:string field's
requirements as well as setting it manually after the form is created
with:

form.element('#no_table_yayweb2py')['requires']=IS_NOT_EMPTY()

The form uses an onvalidation= and again, it works for the plain
string but not a field of list:string

The form is validated no matter what I do.

Your thoughts are most appreciated.

David


[web2py] Re: Ideas for new welcome app

2011-10-18 Thread TheSweetlink
+1 Foundation or Skeleton for mobile friendliness.

Seems much easier than adapting a custom grid.

I found one here a while ago if anyone is interested.  Licensed under
GPL and MIT.

http://www.spry-soft.com/grids/

On Oct 18, 2:01 pm, Anthony abasta...@gmail.com wrote:
 All,

 There are plans to update the 'welcome' scaffolding app, and we are
 considering various front-end frameworks to serve as a base. Here are some
 options being considered:

    - HTML5 Boilerplate (http://html5boilerplate.com)
    - Twitter Bootstrap (http://twitter.github.com/bootstrap)
    - Skeleton (http://www.getskeleton.com)
    - Foundation (http://foundation.zurb.com)

 Note, the latter two (Skeleton and Foundation) offer mobile-friendly
 responsive/adaptive layouts (i.e., use of CSS media queries to automatically
 alter the layout on smaller devices). (When you view those two sites, try
 making your browser window smaller, or view on a smartphone, and see how it
 changes -- won't work in IE9.)

 There's also the possibility of combining these in some way (e.g., Bootstrap
 styles/UI with Skeleton responsive grid).

 The question is, are we missing any good options that should be considered,
 particularly mobile-friendly responsive frameworks? Are there other issues
 we should be thinking about?

 Note, the goal is to have a single, fairly compact 'welcome' app. In
 addition to that, we may offer some alternative scaffolds/layouts via a
 wizard or some kind of repo (perhaps some of those above that aren't
 selected for the 'welcome' app), so the main 'welcome' app doesn't have to
 be all things to all people -- just a nice, basic, general purpose starting
 point (hopefully that's mobile-friendly).

 Suggestions/comments welcome.

 Anthony


[web2py] Re: manual file upload using SQLFORM.factory

2011-10-12 Thread TheSweetlink
I don't think that's how it works.  I get 404 error when trying to
manually download a model.  I'm not sure how but I believe web2py
handles this internally and prevents simple attacks like you're
thinking of.  It may be worth asking the experts though.

On Oct 11, 6:01 pm, Alex mrauc...@gmail.com wrote:
 the files in the uploads folder should be save since they are all
 renamed. But what happens if the user passes e.g. '../models/db.py' as
 parameter? (the slashes would have to be encoded though, is this
 possible?) Then he would get access to the data model which would not
 be good at all. I'm now testing for '..' in the filename, I hope
 that's sufficient and there is no way to circumvent this.

 On 9 Okt., 03:53, TheSweetlink yanosh...@gmail.com wrote:

  Yes a user can by default can download() but how would the user know
  the renamed filename though?  I cannot say as I do not have much
  detail behind your app.  Depending on where you're saving what will
  dictate what you should do better than any advice I can give.  web2py
  enables a great deal of security enhancements by default so generally
  speaking you should be just fine with store() renaming your file.

  Yes, I too have found web2py to be an invaluable tool as well as this
  community being one of the most helpful and nicest around.

  Best,
  David

  On Oct 8, 6:48 am, Alex mrauc...@gmail.com wrote:

   Upload should be save since its handled by web2py. But with the
   download the user possible could pass any path for the filename and
   download files also from other folders. Should I check for '..' in the
   filename? Would it be sufficient?

   btw, the community is great here. as is web2py :)

   Alex




[web2py] Re: confused with install on centos 5.7

2011-10-12 Thread TheSweetlink
CentOS 5 uses an old ver of python I believe but I stopped after 5.6.
The only way I got it to work was under virtualenv and that was after
compiling separate version of python (best not to dump the old version
as yum depends on python 2.4).  As Peter states it will require great
manual labor on your part to get it up and running.

CentOS 6 has python 2.6.5 or something.  web2py is cake on 6.x.  Or if
you're in a bind, virtualenv.

Regards,
David

On Oct 12, 6:56 am, lucas sjluk...@gmail.com wrote:
 hello one and all,

 i have tried to run the web2py install script on a centos 5.7 server.
 it seems to install ok with the addition of adding python 2.6 from
 source and compiling it as well.  after the install script runs,
 apache doesn't restart properly giving the warning NameVirtualHost *:
 80 has no VirtualHosts which leads to an 500 Internal Server Error
 if you access the http interface.

 after reading a bunch of posts under this group for an install on
 centos 5, i am wondering, has anyone gotten web2py to successfully
 work under centos 5.7 or centos 5 and if so, please direct me to the
 thread or solution?

 thank you in advance and have a great day.  lucas


[web2py] Re: IMPORTANT

2011-10-12 Thread TheSweetlink


On Oct 12, 8:08 pm, Daniel Aguayo daniel.agu...@gmail.com wrote:
 El 12/10/11 18:17, Stefaan Himpe escribi :

  Do we need a policy about this?

  live and let live ?

 ++1

 I would be worried if anyone take seriously enough another user signature
 ;3

+1 all of the above for funny and true.


 ... Or perhaps just being aware of this problem is sufficient
 and people will act differently.

Possibly, hopefully the bureaucracy/time/effort involved in such
policy making isn't necessary.

I'd much prefer seeing time spent on this magnificent framework and
its docs.



[web2py] Re: How to create SQLFORM forms in a for loop

2011-10-09 Thread TheSweetlink
I've made something like this work.  Perhaps something like this is
what you're looking for?
*UNTESTED CODE* but same exact concept as what I got to work for me
when making a list of forms.

tags = db(db.tags).select()

# For readability or if you need to do calculations or append more to
your
# SQLFORM
taglist = []
for tag in tags:
taglist.append( SQLFORM(db.tags, record=tag.id, deletable = True,
showid=False, fields=['tag'], labels = {'tag':''}, submit_button =
'update',
delete_label = 'delete ', record_id = None, formstyle = 'table2cols',
separator = '', _name=tag.tag )

# List comprehension is faster than above code though
taglist = [ SQLFORM(db.tags, record=tag.id, deletable = True,
showid=False, fields=['tag'], labels = {'tag':''}, submit_button =
'update',
delete_label = 'delete ', record_id = None, formstyle = 'table2cols',
separator = '', _name=tag.tag) for tag in tags ]

# Ater building your list of forms you need to iterate through it
# and give them an .accepts(...):
for form in taglist:
if form.accepts(request.vars, formname=tag.tag):
response.flash = 'updated'
else:
response.flash = 'form has errors'

Be sure to include taglist=taglist or something to that effect in your
return dict.

I hope this can prove useful to you.

David

On Oct 8, 7:40 pm, monotasker scotti...@gmail.com wrote:
 I need to present a list of edit forms, one for each tag in db.tags. I've
 written the controller below, but it doesn't work because (I think) the
 variable thisform is identical for each form. I think the problem is that
 I need to assign a unique variable name to each form (i.e., each time
 through the for loop). But since you can't use operators in a variable
 name, I'm not sure if this is possible. Is there a simple solution?

 tags = db(db.tags).select()
 taglist = []
 for tag in tags:
             thisform = SQLFORM(db.tags, record=tag.id, deletable = True,
 showid=False, fields=['tag'], labels = {'tag':''}, submit_button = 'update',
 delete_label = 'delete ', record_id = None, formstyle = 'table2cols',
 separator = '', _name=tag.tag)
             if thisform.accepts(request.vars, formname=tag.tag):
                 response.flash = 'updated'
             else:
                 response.flash = 'form has errors'
             taglist.extend(thisform)


[web2py] Re: manual file upload using SQLFORM.factory

2011-10-08 Thread TheSweetlink
Yes a user can by default can download() but how would the user know
the renamed filename though?  I cannot say as I do not have much
detail behind your app.  Depending on where you're saving what will
dictate what you should do better than any advice I can give.  web2py
enables a great deal of security enhancements by default so generally
speaking you should be just fine with store() renaming your file.

Yes, I too have found web2py to be an invaluable tool as well as this
community being one of the most helpful and nicest around.

Best,
David

On Oct 8, 6:48 am, Alex mrauc...@gmail.com wrote:
 Upload should be save since its handled by web2py. But with the
 download the user possible could pass any path for the filename and
 download files also from other folders. Should I check for '..' in the
 filename? Would it be sufficient?

 btw, the community is great here. as is web2py :)

 Alex



[web2py] Re: manual file upload using SQLFORM.factory

2011-10-07 Thread TheSweetlink
I'm happy the upload works for you Alex.

 do I have to take care about directory traversals and other security
 risks? What's the easiest way to do this?

As I understand it the store() renaming of the file is what takes care
of the dir traversal protection.

I'm not a web2py dev so don't quote me on that.

Perhaps you lot can confirm?

David


[web2py] Re: Dealing with UTC and converting to local time

2011-10-06 Thread TheSweetlink
For those interested in timezones and your international site I found
a nice js script after much hunting to detect utc timezone offset,
whether or not it is DST, and the hemisphere of the client.

https://bitbucket.org/pellepim/jstimezonedetect

Another plus:  Provided under the Do Whatever You Want With This Code
License.

Enjoy.

-David

On Oct 5, 10:20 am, Farsheed Ashouri farsheed.asho...@gmail.com
wrote:
 Thank you Massimo, You solution is very good. I am using a javascript code
 that detects timezone and other things, but i should change it to your way
 for sure. Although this script does the job for me but it's more
 complicated.

  detect_timezone.js
 13KViewDownload


[web2py] Re: manual file upload using SQLFORM.factory

2011-10-06 Thread TheSweetlink
My pleasure Alex.  I am glad that worked out for you.  Now that I look
at your code you got it to work in a way I didn't even think of.  May
we see a more complete example of your SQLFORM.factory?

Massimo,
I don't think I would know how to make it better other than Alex's
suggestion of adding some more info to the Book.

Especially when Alex came up with another way to do the manual upload
I think it's cool that web2py is that flexible.

I know it must be difficult to keep it all up to date with all the new
features cropping up left and right.  Nice work by the way to all that
did the most recent updates.

Viva web2py and its magnificent community,
David

On Oct 6, 4:12 pm, Alex mrauc...@gmail.com wrote:
 Hi David,

 works great, thanks!

 I'm now manually uploading with these few lines:
 field = Field('invoice_logo', 'upload',
 uploadfolder=os.path.join(request.folder,'uploads/'))
 field._tablename = 'admin_setting'
 uploaded_invoice_logo_filename =
 field.store(request.vars.invoice_logo.file,
 request.vars.invoice_logo.filename)

 @Massimo: now that I know, it's quite easy so I don't know much to
 make it better. It would be good if this would be mentioned in the
 documentation (there is already a short 'Manual Uploads' section),
 although this is probably not a common use case. And maybe it would be
 a good idea to have default values for uploadfolder and tablename?

 On 6 Okt., 03:46, Massimo Di Pierro massimo.dipie...@gmail.com
 wrote:

  Suggestions to make the behaviour better?

  On Oct 5, 5:55 pm, TheSweetlink yanosh...@gmail.com wrote:

   Hello Alex,

   Two things I've found when manually uploading via SQLFORM.factory:

   1)  You need to specify a table_name='...' to avoid the
   no_table_newfilename.extension issue like this:

   form = SQLFORM.factory(...Field definitions...,
   table_name='some_table_name')

   2)  Additionally you must specify an uploadfolder in your upload Field
   definition similar to this:

   form = SQLFORM.factory(...,
   Field('invoice_logo', type='upload',
   uploadfolder=os.path.join(request.folder,'static/uploads/')),
   ..., table_name='whatever_you_like')

   **NOTE** 'static/uploads' is just an example, you can upload to
   wherever it will be appropriate.

   In this case the newly uploaded and renamed file to
   your_application's_dir/static/uploads/your_new_filename_here

   One gotcha to look out for following your field name as an example
   without the quotation marks:

   In your form.accepts(...):

   request.vars.invoice_logo will contain the original filename of your
   upload whereas

   form.vars.invoice_logo_newfilename will contain the newly renamed
   file like yourtablename.9203842903.thaoeu09gu023hgda3p.ext

   No need to call store() directly as SQLFORM.factory will take care of
   that for you.

   I hope that this helps you.

   -David Bloom

   On Oct 4, 7:53 pm, Alex mrauc...@gmail.com wrote:

Hi,

I've already spent quite some time with the following problem which I
think should be fairly easy. I hope someone can help me.

# model
db.define_table('admin_setting',
    Field('name', 'string', notnull=True),
    Field('value', 'string', notnull=True))

in the controller I'm creating a form for various admin settings.
form = SQLFORM.factory(
        Field('invoice_logo', 'upload'), ...)

the view works well and displays all fields.

When uploading a file for the logo the file should be handled like
always (file uploaded to uploads folder, renamed to uuid filename). in
the table admin_setting I want to store the filename of the uploaded
file in a row where name='invoice_logo' (the filename should be stored
in the value field).

How can I achieve this? currently I have this code (the update is
performed later and not shown here):
if form.accepts(request.vars, formname='admin_setting_form',
dbio=False):
  if request.vars.invoice_logo != None:
    if type(request.vars.invoice_logo) != str:
      request.vars.invoice_logo_filename =
request.vars.invoice_logo.filename
      field = Field('invoice_logo', 'upload')
      # field.store fails because field does not have a _tablename
      uploaded_file = field.store(request.vars.invoice_logo.file,
request.vars.invoice_logo.filename)
    else:
       del request.vars.invoice_logo # do not delete existing logo




[web2py] Re: criticism of web2py

2011-10-06 Thread TheSweetlink
+1

Coming from PHP months ago I had never touched python or anything
python related but was drawn to it by an article on how Disqus used
python and the whole MVC concept.

Tried Django but was met with less than nice responses when asking
questions while reading their book.

Found web2py as I like to hunt for all options before choosing and
found myself well aligned with web2py philosophies.

Just to name a few:
Default sane behaviour with easy ability to override,
Simple is better than complex,
Don't Repeat Yourself,
and my most favorite feature - An effort to be a COMPLETE and fully
integrated package.  I really prefer this to the glue frameworks out
there.

The book taught me python and web2py simultaneously and inspired me to
hunt all over for as much information as possible about python as I
can find.

As far as I'm concerned, if someone chooses another framework because
it makes them feel more 1337 that their using something tougher/more
pythonic in their view/insert subjective term here, fine.  If their
priest.py doesn't approve it as Roberto De Ioris humorously put it
above, good.  More secret sauce for us.

Still, I will continue to tell people about this amazing tool I've
found and the wonderful community behind it and look forward to web2py
winning more awards and accolades from the world over.

Congrats Massimo, contributors, and community.  Whether directly or
indirectly, you have all impacted my life for the better and I thank
you all for it.

David



On Oct 5, 8:37 pm, horridohobbyist horrido.hobb...@gmail.com wrote:
 I like web2py. I think it's the best web framework out there...

 Let me explain where I'm coming from. My first experience as a web
 developer was with Smalltalk/Seaside in 2007. It came highly
 recommended to me by a friend. He told me that Seaside was very
 powerful, very flexible, and most importantly, really easy to learn. I
 value productivity and ease of use above all else when it comes to
 software development. I don't care about ideology or the ultimate in
 power and performance.

 My Seaside project was completed in record time. I was a happy camper.

 My attitude is definitely non-geek-like. I am not a geek. I only
 care about getting the job done in the shortest time, with the least
 effort and the least pain. This has been my guiding principle over a
 20-year career in IT (ranging from Fortran to C, from mainframe to
 PC).

 A year ago, I took a whack at Django, but I did not like it. I also
 tried Java-based Wicket. But neither passed the acid test of being
 really easy to learn and use.

 When I came across web2py a couple of months ago, I was utterly
 astonished. For a newbie, it's fall-off-the-log easy to pick up.
 That's important to me. And being easy to use doesn't mean that it's
 lacking in power. I can be phenomenally productive with web2py.

 My conclusion is that web2py is actually easier than Seaside
 (heresy!). It's also easier than Django, and it's definitely much
 easier than Wicket. I can't understand why programmers don't want the
 easiest tools. I prefer to enjoy my life, take it easy, rather than
 expose myself to aggravation and headache, regardless of how much
 power you gain.

 But that's just me.

 Richard

 On Oct 5, 10:07 am, Farsheed Ashouri farsheed.asho...@gmail.com
 wrote:

  i bet they event didn't create a simple site with Web2py. Don't trust them.
  Just for test, use Django for a week and you'll be back to Web2py soon than
  we expected and with headaches!!
  Every day, I am creating a new website for my clients. When I was using
  Django, just initial setup took me hours. I am not saying other frameworks
  are not smart. Web2Py is just better.




[web2py] Re: Dealing with UTC and converting to local time

2011-10-05 Thread TheSweetlink
Thank you kindly Massimo.

I am storing the data in OrientDB so will be unable to test the time
shift field representation b it looks so clean and simple.

However I think I can store everything as UTC with your first tip and
use JS to detect the user's timezone and convert the UTC to local in
JS returned in a view.

Is that correct?

-David



On Oct 4, 11:36 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 request.now = request.utcnow

 on top of db.py will make sure internally you have request.utcnow
 everwhere.

 Then you can set

 shift=datetime.timedelta()
 db.table.field.represent = lambda d,r,s=shift: prettydate(d+s)

 for all tables and fields where shift is the localtion-uct time shift.
 To compute it you need to know where the visitor it.

 On Oct 4, 6:39 pm, TheSweetlink yanosh...@gmail.com wrote:

  I want to insert all posts in UTC and convert to local time with
  prettydates.

  Either the gluon.tools prettydate() or a JS script I got a hold of
  convert the time properly.

  How could I insert a record that is UTC timestamped in the db but
  converted to local timezone when retrieving and viewing the record?

  Thanks in advance.

  -David




[web2py] Re: Dealing with UTC and converting to local time

2011-10-05 Thread TheSweetlink
Thank you too Farsheed.  Didn't mean to leave you out there :)

-David

On Oct 5, 10:20 am, Farsheed Ashouri farsheed.asho...@gmail.com
wrote:
 Thank you Massimo, You solution is very good. I am using a javascript code
 that detects timezone and other things, but i should change it to your way
 for sure. Although this script does the job for me but it's more
 complicated.

  detect_timezone.js
 13KViewDownload


[web2py] Re: How to start something when page rendering has completed?

2011-10-05 Thread TheSweetlink
Thank you so much Farsheed.  I will test this and post my findings.
Pubsub over polling would save me a ton of bandwidth.

-David

On Oct 5, 1:52 pm, Farsheed Ashouri farsheed.asho...@gmail.com
wrote:
 Put something like this at the end of your page:

 div id=jsrun/div
 script
 ajax('../response_url', [''], 'jsrun');
 /script

 create a function that returns data:

 def response_url():
     return '''
                YOUR DATA OR EVEN JSSCRIPT HERE
                '''


[web2py] Re: How to start something when page rendering has completed?

2011-10-05 Thread TheSweetlink
No errors but no running of the listener.next() either.  I tried to
put the function declaration above the {{extend...}} statement as per
the book but still no go.

I get up to subscribing to the channel just fine (but that's from
controller and passed to the view) verified via telnet to Redis but
can't seem to tell the listener to wait for new messages without
mucking everything up.

Thank you for your help anyway Farsheed.  I'll fiddle with it a bit
more but if I cannot produce meaningful results I'll be doomed to
poll.  Not the end of the world but less than ideal.  So it goes.

-David

On Oct 5, 1:52 pm, Farsheed Ashouri farsheed.asho...@gmail.com
wrote:
 Put something like this at the end of your page:

 div id=jsrun/div
 script
 ajax('../response_url', [''], 'jsrun');
 /script

 create a function that returns data:

 def response_url():
     return '''
                YOUR DATA OR EVEN JSSCRIPT HERE
                '''


[web2py] Re: manual file upload using SQLFORM.factory

2011-10-05 Thread TheSweetlink
Hello Alex,

Two things I've found when manually uploading via SQLFORM.factory:

1)  You need to specify a table_name='...' to avoid the
no_table_newfilename.extension issue like this:

form = SQLFORM.factory(...Field definitions...,
table_name='some_table_name')

2)  Additionally you must specify an uploadfolder in your upload Field
definition similar to this:

form = SQLFORM.factory(...,
Field('invoice_logo', type='upload',
uploadfolder=os.path.join(request.folder,'static/uploads/')),
..., table_name='whatever_you_like')

**NOTE** 'static/uploads' is just an example, you can upload to
wherever it will be appropriate.

In this case the newly uploaded and renamed file to
your_application's_dir/static/uploads/your_new_filename_here

One gotcha to look out for following your field name as an example
without the quotation marks:

In your form.accepts(...):

request.vars.invoice_logo will contain the original filename of your
upload whereas

form.vars.invoice_logo_newfilename will contain the newly renamed
file like yourtablename.9203842903.thaoeu09gu023hgda3p.ext

No need to call store() directly as SQLFORM.factory will take care of
that for you.

I hope that this helps you.

-David Bloom

On Oct 4, 7:53 pm, Alex mrauc...@gmail.com wrote:
 Hi,

 I've already spent quite some time with the following problem which I
 think should be fairly easy. I hope someone can help me.

 # model
 db.define_table('admin_setting',
     Field('name', 'string', notnull=True),
     Field('value', 'string', notnull=True))

 in the controller I'm creating a form for various admin settings.
 form = SQLFORM.factory(
         Field('invoice_logo', 'upload'), ...)

 the view works well and displays all fields.

 When uploading a file for the logo the file should be handled like
 always (file uploaded to uploads folder, renamed to uuid filename). in
 the table admin_setting I want to store the filename of the uploaded
 file in a row where name='invoice_logo' (the filename should be stored
 in the value field).

 How can I achieve this? currently I have this code (the update is
 performed later and not shown here):
 if form.accepts(request.vars, formname='admin_setting_form',
 dbio=False):
   if request.vars.invoice_logo != None:
     if type(request.vars.invoice_logo) != str:
       request.vars.invoice_logo_filename =
 request.vars.invoice_logo.filename
       field = Field('invoice_logo', 'upload')
       # field.store fails because field does not have a _tablename
       uploaded_file = field.store(request.vars.invoice_logo.file,
 request.vars.invoice_logo.filename)
     else:
        del request.vars.invoice_logo # do not delete existing logo


[web2py] reqeust.now and datetime.datetime.now() off by 2 minutes?

2011-10-04 Thread TheSweetlink
On a VM running latest stable, ntpd running on both guest as well as
host so I don't know what I'm missing here.

I know this must be a really simple one but I could use a push in the
right direction please.

Thank you in advance for your help.

-David


[web2py] Re: reqeust.now and datetime.datetime.now() off by 2 minutes?

2011-10-04 Thread TheSweetlink
Truly bizarre.

When I put timetest() in default.py and test it it works a treat.

output:
2011-10-04 18:40:07.876602 ## 2011-10-04 18:40:07.894192


If I run from the commandline (importing models and such as I normally
do to test things):

print request.now, datetime.datetime.now()

produces:
2011-10-04 18:36:04.232022 2011-10-04 18:41:02.857936

I just learned that request.now doesn't even change anymore when run
from cli but datetime.datetime.now() does.  request.now just stays at
the time I started web2py from the cli.

In the past I have done the following to test small pieces of my code
/my_path_to_web2py/web2py.py -S init -M -N

Am I doing something wrong?

request.now used to be now now (and it is in the browser apparently)
like in Spaceballs but clearly I've past then...just now.

This is all in an effort to poll a controller function to check for
new messages and refresh a component when there is a newer timestamp
compared to last message received.  The problem is my newly inserted
messages kept showing up as in the past so the polling won't trigger a
refresh.

Preferrably, I could use Redis' pubsub, subscribe to a channel and
publish a message to signal refresh of the component.

I made a bit of progress with Redis' pubsub but cannot figure out how
to completely render the page and then start the pubsub's
listener.next().

It is a blocking call that holds everything up waiting for new
messages on the subscribed channel so I figured polling is the way to
go for now.

I just remembered another possibility that it could be VM related.
Guest is Centos 6 and I recall 5.x had some really screwy timing
issues.  I'll look into that.

Grumblegrumble, back to the drawing board.

Thanks for your help pbreit.

-David


On Oct 4, 5:25 pm, pbreit pbreitenb...@gmail.com wrote:
 Is it isolated something like this?

 def timetest():
     import datetime
     return '%s ## %s' % (request.now, datetime.datetime.now())

 2011-10-04 14:23:41.505797 ## 2011-10-04 14:23:41.536510


[web2py] Dealing with UTC and converting to local time

2011-10-04 Thread TheSweetlink
I want to insert all posts in UTC and convert to local time with
prettydates.

Either the gluon.tools prettydate() or a JS script I got a hold of
convert the time properly.

How could I insert a record that is UTC timestamped in the db but
converted to local timezone when retrieving and viewing the record?

Thanks in advance.

-David


[web2py] Re: reqeust.now and datetime.datetime.now() off by 2 minutes?

2011-10-04 Thread TheSweetlink
I suspected this after some trial and error.  Makes sense just like
the rest of the framework.  Thank you Anthony.

May I hijack my own thread and ask you about the Redis pubsub issue I
am having?

I can subscribe to channels, post messages to them and receive them
fine from the shell but don't know how to approach it in the context
of a web2py request with a view.

Is there a way to render the page completely and then issue
the .next() blocking call to wait for messages on the subscribed
channels or am I doomed to poll for new data?

The idea was to be able to refresh a component using a pubsub signal
only when there is new data rather than poll for new data but I cannot
figure out how to work in that .next() which blocks everything until
there is a message on the subscribed channel.

All I can do is almost render the page and if there is any call to the
listener to wait for new messages it won't finish rendering until I
send a message to the subscribed channel which defeats the purpose.

If it's a pipe dream so be it but if you don't ask you don't get.

Thanks again for your help.

-David

On Oct 4, 9:22 pm, Anthony abasta...@gmail.com wrote:
 request.now is set each time a new request comes in and is specific to that
 request. When you start the shell, there are no requests coming in to the
 shell -- so request.now is set when the shell is first started, and there's
 nothing to change it after that. The shell basically gives you a web2py
 environment in the context of a single request.

 Anthony

 On Tuesday, October 4, 2011 7:08:26 PM UTC-4, TheSweetlink wrote:

  Truly bizarre.

  When I put timetest() in default.py and test it it works a treat.

  output:
  2011-10-04 18:40:07.876602 ## 2011-10-04 18:40:07.894192

  If I run from the commandline (importing models and such as I normally
  do to test things):

  print request.now, datetime.datetime.now()

  produces:
  2011-10-04 18:36:04.232022 2011-10-04 18:41:02.857936

  I just learned that request.now doesn't even change anymore when run
  from cli but datetime.datetime.now() does.  request.now just stays at
  the time I started web2py from the cli.

  In the past I have done the following to test small pieces of my code
  /my_path_to_web2py/web2py.py -S init -M -N

  Am I doing something wrong?

  request.now used to be now now (and it is in the browser apparently)
  like in Spaceballs but clearly I've past then...just now.

  This is all in an effort to poll a controller function to check for
  new messages and refresh a component when there is a newer timestamp
  compared to last message received.  The problem is my newly inserted
  messages kept showing up as in the past so the polling won't trigger a
  refresh.

  Preferrably, I could use Redis' pubsub, subscribe to a channel and
  publish a message to signal refresh of the component.

  I made a bit of progress with Redis' pubsub but cannot figure out how
  to completely render the page and then start the pubsub's
  listener.next().

  It is a blocking call that holds everything up waiting for new
  messages on the subscribed channel so I figured polling is the way to
  go for now.

  I just remembered another possibility that it could be VM related.
  Guest is Centos 6 and I recall 5.x had some really screwy timing
  issues.  I'll look into that.

  Grumblegrumble, back to the drawing board.

  Thanks for your help pbreit.

  -David

  On Oct 4, 5:25 pm, pbreit pbreit...@gmail.com wrote:
   Is it isolated something like this?

   def timetest():
       import datetime
       return '%s ## %s' % (request.now, datetime.datetime.now())

   2011-10-04 14:23:41.505797 ## 2011-10-04 14:23:41.536510




[web2py] Re: Adding hidden field to a form

2011-10-04 Thread TheSweetlink
I believe your FORM needs a totalitems field or INPUT.  At least
that's what I experienced with SQLFORM.factory.

Needed a Field('totalitems', readable=False, writable=False) to match
if I was passing hidden=dict(totalitems='1').

I often choose SQLFORM or .factory for the ability to customize the
form in the view with CSS.

I have not tested this but perhaps adding an INPUT(_type='hidden',
_name='totalitems', _value='1') to your FORM may work.

Maybe look into SQLFORM and SQLFORM.factory 
http://web2py.com/book/default/chapter/07

Best of luck and I'm sure at least one genius on this list will have
the answer if I wasn't of any help, this community is almost
unbelievably helpful...almost :)

-David


On Sep 28, 10:14 pm, Joseph Jude ceph...@gmail.com wrote:
 Hi,
 I define the below form in controller but the hidden field is not present in
 the view. Note that, field 'totalitems' is not in the db. Let me know how to
 add hidden fields to FORM.

 form = FORM(
 DIV(
 LABEL(Checklist Items:),
 UL(
 SPAN(INPUT(_type=text, _name=citems),
 IMG(_class=add, _src=URL('static', 'images/add.png')),
 IMG(_class=remove,_src=URL('static', 'images/delete.png'))),
 ),
 hidden=dict(totalitems='1')
 ))
 Thank you,
 Joseph


[web2py] Re: Multiple tables, one form with image upload

2011-10-03 Thread TheSweetlink
Hello pbreit,

I cannot find the post on this group where I found it but I'm pretty
sure form.vars.filename_newfilename is what you're looking for.

This is not to be confused with request.vars.filename.filename which
will contain your original filename.  form.vars.filename_filename will
contain the new filename returned by store()

Rather than using two tables from models I am defining my Fields
directly in my SQLFORM.factory but that shouldn't matter in this case.

I have successfully uploaded files to the filesystem having
SQLFORM.factory calling store() and renaming the file for me.

I had to specify an uploadfolder similar to
uploadfolder=os.path.join(request.folder,'static/uploads/') in my
SQLFORM.factory.  (Just realized that's what you helped me with a few
days ago.)

Try this in your db.image.insert(...):

def newpost():
form = SQLFORM.factory(db.post, db.image)
if form.process().accepted:
post_id = db.post.insert(**db.post._filter_fields(form.vars))
db.image.insert(post_id=post_id,
filename=form.vars.filename_newfilename)
redirect(URL('post', args=post_id))
return dict(form=form)


-David

On Oct 2, 4:23 am, pbreit pbreitenb...@gmail.com wrote:
 I can't seem to figure out how to do multiple tables in one form where an
 image upload is involved. I've tried various combinations of this.
 Unfortunately I'm not getting meaningful error messages right now,
 everything is listed as timed out.

 db.define_table('post',
     Field('title'),
     Field('body', 'text'))

 db.define_table('image',
     Field('post_id', db.post, readable=False, writable=False),
     Field('filename', 'upload'))

 def newpost():
     form = SQLFORM.factory(db.post, db.image)
     if form.process().accepted:
         post_id = db.post.insert(**db.post._filter_fields(form.vars))
         db.image.insert(post_id=post_id,
             filename=db.image.filename.store(form.vars.filename.file,
 form.vars.filename.filename))
         redirect(URL('post', args=post_id))
     return dict(form=form)


[web2py] How to start something when page rendering has completed?

2011-10-03 Thread TheSweetlink
Please help me with your suggestions.

I'm playing with Redis pub/sub via redis-py as a possible method to
reload a component in a page instead of polling.

In its simplest form the idea is:

1)  create pubsub object
2)  subscribe it to one or more channels (just one in this case)
3)  create listen object to listen to subscribed channels
4)  listen object calls .next() --- stuck here
5)  new message published to channel triggers component reload

Everything works great on at a python CLI however I cannot seem to
figure out one crucial detail.

When I start the listener object to check for new messages it is a
blocking call so it prevents the page from completely loading while
waiting for a new message on the channel it is subscribed to.

I tried putting listener.next() at the end of my view but it prevents
my page from working properly as it just blocks waiting for a new
message.  A new message allows the page to complete loading but that
defeats the purpose.

How can I completely load my page and then start listening to Redis'
pubsub for new messages?

Your thoughts are most appreciated.

-David


Re: [web2py] Dynamic Model

2011-09-29 Thread TheSweetlink
I have recently found OrientDB http://orientechnologies.com

It is a document-graph db that will allow you to evolve your schema
over time.  In fact you can have no schema, mixed-schema, or full
schema.  There is SQL syntax that is both familiar and powerful,
especially when combined with Gremlin the graph traversal language.

OrientDB is VERY FAST in my initial testing.  Massimo might write an
adapter in the future to make it more integrated with web2py but in
the meantime I have had great success using the requests python
library to access OrientDB via its RESTful API.

The community behind OrientDB has been as helpful to me as the web2py
community has been which is monumentally helpful to say the least.

Best of luck,
David

Phyo Arkar wrote:
 Couch ? Mongo?
 I really have to try them , not started yet.

 On Thu, Sep 29, 2011 at 4:28 AM, pbreit pbreitenb...@gmail.com wrote:

  NoSQL


[web2py] Re: How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-28 Thread TheSweetlink
Please disregard and forgive the list spam.

I adapted some of the file renaming code from store() in dal.py to
manually rename the file and everything worked out.

Thanks Massimo and contributers once again for the amazing code we all
benefit from.

-David



[web2py] Re: How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-28 Thread TheSweetlink
I spoke too soon.

SQLFORM.factory is doing the proper renaming and uploading of the file
to the filesystem but I still cannot get the new filename
no_table.sirgallahad.823497htn7crh743uo5e4.ext

I can only retrieve the original filename with no path a la
request.vars.sirgallahad.filename

After searching the mail list I can only find one post re:
request.vars.sirgallahad_newfilename but that doesn't return
anything.  Interestingly enough it doesn't break anything either.

Please advise as to how I can get the no_table.sirgallahad.
0879euitheui098oeunht.ext

Thank you.

-David


[web2py] Re: How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-28 Thread TheSweetlink
Got it!

My problem was using request.vars.bridgetroll.filename when I should
have used form.vars.bridgetroll_newfilename

Will read more carefully next time.

/list spam

-David


[web2py] Re: How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-28 Thread TheSweetlink
A different but related problem.

Now that I have the file on the filesystem with the nice web2py
renaming to prevent directory traversal attack, I cannot use the
default download function to download my newly uploaded file.

type 'exceptions.KeyError'('no_table')

This is because I'm using SQLFORM.factory and dal.py store() adds
no_table to the beginning of my filename as expected.

Why should no_table break downloading my image file?

Please advise.

-David


[web2py] Re: How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-28 Thread TheSweetlink
Thank you so much Carlos.  How noobtastic of me to not think of that
one.

-David

On Sep 28, 3:03 pm, Carlos carlosgali...@gmail.com wrote:
 Hi,

 This occurred to me too, and I had to use the 'table_name' argument in the
 SQLFORM that handles the factory.

 I hope this helps.

    Carlos


[web2py] What is the recommended method for retrieving a file which was uploaded manually via SQLFORM.factory?

2011-09-28 Thread TheSweetlink
SQLFORM.factory renames and uploads my file to uploads/ dir via
store() in dal.py  great.

In form.accepts (will refactor code to use .process() soon) I store
the new filename in a currently unsupported db.

What is the safe/proper/best way to retrieve my file?

I know the renamed filename but since there is no table defined in a
model the web2py download function won't work for me.  It requires db.

The only way I can think of is opening the file with plain python and
skipping the download function altogether.

Would skipping the download function open my app up to security
hazards?  I planned to use it with authorization but that's a no go
without a model.

I appreciate anyone pointing me in the right direction.  Thank you.

-David Bloom


[web2py] Re: What is the recommended method for retrieving a file which was uploaded manually via SQLFORM.factory?

2011-09-28 Thread TheSweetlink
Hi Massimo!

It is not my intention to bypass anything as I'd prefer you experts to
do the framework business.  Rather, I wish to know what the best
course of action would be.

I cannot retrieve a file which was uploaded using SQLFORM.factory

My SQLFORM.factory renames and places my file on the filesystem via
store() in dal.py, excellent.

I cannot use URL('default', 'download', args=spam) as it throws an
type 'exceptions.KeyError'('spam')

I believe the issue stems from my only table defined in models are for
auth and I'm using OrientDB for everything else.

So when I call download() there is no table for it to reference to get
the filename.

How should I go about retrieving the file I uploaded with my
SQLFORM.factory?

At the cost of sounding repetitious, thank you Massimo.  My positive
experiences with this community is part of what drove me towards
web2py and away from other projects.

-David

On Sep 28, 7:25 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Before we get into this discussion. Why are you bypassing the normal
 mechanism?

 Massimo

 On Sep 28, 5:51 pm, TheSweetlink yanosh...@gmail.com wrote:

  SQLFORM.factory renames and uploads my file to uploads/ dir via
  store() in dal.py  great.

  In form.accepts (will refactor code to use .process() soon) I store
  the new filename in a currently unsupported db.

  What is the safe/proper/best way to retrieve my file?

  I know the renamed filename but since there is no table defined in a
  model the web2py download function won't work for me.  It requires db.

  The only way I can think of is opening the file with plain python and
  skipping the download function altogether.

  Would skipping the download function open my app up to security
  hazards?  I planned to use it with authorization but that's a no go
  without a model.

  I appreciate anyone pointing me in the right direction.  Thank you.

  -David Bloom




[web2py] Re: What is the recommended method for retrieving a file which was uploaded manually via SQLFORM.factory?

2011-09-28 Thread TheSweetlink
Thanks to Carlos Galindo for the tip.  He helped me earlier today.

I am not using web2py's auth to download the uploaded files, I just
reference them directly with URL('static', 'myfolder/' +
uploadfieldvalue) ... where uploadfieldvalue is the uploaded file name
stored in the field.

I believe his solution is what I need.

Massimo would you be kind enough to confirm this?

-David


[web2py] Re: What is the recommended method for retrieving a file which was uploaded manually via SQLFORM.factory?

2011-09-28 Thread TheSweetlink
Awesome, thank you pbreit.

I cannot get over helpful this community is.

-David

On Sep 28, 9:01 pm, pbreit pbreitenb...@gmail.com wrote:
 I store my images in a different folder and serve them directly:

     Field('image', 'upload', uploadfolder=request.folder+'static/uploads',
             requires=IS_EMPTY_OR(IS_IMAGE())),


[web2py] How do I get the encoded filename from SQLFORM.factory upload field.

2011-09-27 Thread TheSweetlink
I am attempting to insert the new encoded filename of my upload into
an unsupported db manually.

I have a SQLFORM.factory with an upload field that works fine.  It
uploads my file to disk and goes through store() from dal.py renaming
my uploaded file as expected.  no_table.a_witch

My problem is that I can only retrieve the original filename in
request.vars.a_witch.filename and I want the new name of
no_table.a_witch.01987thaeoo789oefu32...

How can I accomplish this?

Thank you in advance for your help.

-David


[web2py] Re: what about web2py 2.0?

2011-09-21 Thread TheSweetlink
+1 DAL support for Document-Graph database OrientDB and thank you very
much for your work Massimo + contributors.


[web2py] redis_cache.py and sessions?

2011-09-14 Thread TheSweetlink
I would love to be able to stick sessions in Redis.

Is that a possibility with redis_cache.py?

I tried it but was unable to get it to work.  MEMDB complained about
type 'exceptions.AttributeError'('RedisClient' object has no
attribute 'incr')

If I use redis-py from pip as a plain cache I am able to incr values
so I have no idea why that's the failure.

Versions
web2py:  trunk
nginx:  1.0.6
uWSGI:   0.9.9.2
Redis: 2.4.0-rc7

Please see the following paste for model and more verbose error junk.
http://paste.pocoo.org/show/476195/

Thank you in advance for your help and thank you all for your work on
the upcoming release.

-David Bloom


[web2py] Re: redis_cache.py and sessions?

2011-09-14 Thread TheSweetlink
Thank you Massimo.

Would you be so kind as to point me in the direction of where I could
learn to do that with web2py?

Are there any security implications?  I would imagine the digitally
signing takes care of that.

Is that done with that secure cookies post from a while back?

-David

On Sep 14, 11:11 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Not yet. Sessons for now go in filesystem or db only, they cannot go
 on cache.

 Actually, I would digitally sign sessions and store them client-side
 than store them in cache.

 massimo

 On Sep 14, 7:49 pm, TheSweetlink yanosh...@gmail.com wrote:

  I would love to be able to stick sessions in Redis.

  Is that a possibility with redis_cache.py?

  I tried it but was unable to get it to work.  MEMDB complained about
  type 'exceptions.AttributeError'('RedisClient' object has no
  attribute 'incr')

  If I use redis-py from pip as a plain cache I am able to incr values
  so I have no idea why that's the failure.

  Versions
  web2py:  trunk
  nginx:      1.0.6
  uWSGI:   0.9.9.2
  Redis:     2.4.0-rc7

  Please see the following paste for model and more verbose error 
  junk.http://paste.pocoo.org/show/476195/

  Thank you in advance for your help and thank you all for your work on
  the upcoming release.

  -David Bloom




[web2py] Re: web2py received 2011 BOSSIE Award by InfoWorld.com

2011-09-09 Thread TheSweetlink
Well deserved and looking forward to a pile of awards going forward.
Web2py and its community are a delight.  Congrats.

-David

On Sep 9, 3:20 am, paroiron cont...@guitares-roiron.com wrote:
 Congratulations!


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-09-04 Thread TheSweetlink
Hello Nicolas,

I am not familiar with endeca so I cannot speak specifically to that
product.  What I can do is provide you with a list of reasons that
brought me to use OrientDB with my web2py project.

This is a far from exhaustive list but rather some of the OrientDB
specific features which happened to fit my project best:

- Ability to have schema-full, schema-mixed, schema-less data all in
one DB.  The combination of Document db and Graph db is a big deal
because you can evolve your data over time without breaking/slowing/
hurting/rebooting/running 2 month long queries to add one column of
data to the running system.
- SQL syntax is both familiar to me and can be easily adapted to DAL.
- GREMLIN graph traversal language bundled in is able to be combined
with SQL sytax allowing for very powerful queries on your graph.
  -- Yes Gremlin is available for many other graph dbs but none others
have SQL syntax that can be combined with Gremlin.
- Apache 2.0 license is very liberal.  Free for any use.
- Built in clustering for distributed/high availability setups.
  -- Neo4j has clustering too but only under commercial license as I
understand it.
- Initial testing (more required) of my application revealed OrientDB
pulling relevant data in 1-7 ms versus 80-90 in a traditional RDBMS.
- Luca Garulli is all over all forums Massimo style with helpful
answers and rapid development.
- Pro support and training is available.
- web2py, OrientDB, Gremlin have been the 3 most informative and
helpful communities I have ever encountered = great for long term
usage.


For more complete information go to http://www.orientechnologies.com
the home of OrientDB.  Do go there and click the Documentation button
to learn more about OrientDB.  The wiki is very informative.

Warm Regards,
David Bloom


On Sep 4, 2:04 pm, Nicolas Palumbo napalu...@gmail.com wrote:
 what is the difference between orientDB and other graph databases? like endeca



 On Sat, Sep 3, 2011 at 11:12 PM, TheSweetlink yanosh...@gmail.com wrote:
  I have tested bulbs with Rexster and while they are great products
  with an equally great community, there are some existing
  incompatibilities that prevent usage of OrientDB's remote engine.
  This is the only one that allows multiple connections to a db as well
  as the built-in clustering capabilities.  It is being worked on to my
  understanding and will work in the future.

  With regards to bulbs, it is really cool stuff but so abstract that
  you cannot take advantage of many of OrientDB specific features.
  Namely, schema, indicies work differently, possibly others I cannot
  think of.  I love the whole Tinkerpop stack and Rexster/bulbs, will
  definitely use them, but not sure if it's a clean fit for an OrientDB
  -- web2py specific adapter.  The concept of being able to use bulbs
  for all of those datastores would bring even more flexibility so it's
  rather appealing in that sense.

  -David

  On Sep 3, 7:16 pm, Vasile Ermicioi elff...@gmail.com wrote:
  what do you think if we will write and adapter on top of rexter (or
  bulbflow)? we will have an adapter for all rexster graph databases
  (TinkerGraph, Neo4j, OrientDB, DEX, and Sail RDF Stores)

 http://code.google.com/p/orient/wiki/ProgrammingLanguageBindings#Lang...


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-09-03 Thread TheSweetlink
That is thrilling news Massimo.  Issue #407.  Having strong
integration between web2py and OrientDB will allow for some truly
amazing products on top of the already amazing capabilities of web2py.

Please tell me what could use testing lately and how I can find that
information out without bugging you all the time for it.  I couldn't
seem to get web2py-celery to even start if you recall, ugh and after
getting all those dependencies.  Perhaps can test something else more
usefully?

-David Bloom

On Sep 2, 8:07 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I am interested but this will be postponed a little bit. Please open
 an issue so we will remember.

 On Sep 2, 1:31 am, David Marko dma...@tiscali.cz wrote:



  Let me know of your progress on OrientDB integration. I can help with
  testing ...


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-09-03 Thread TheSweetlink
I have tested bulbs with Rexster and while they are great products
with an equally great community, there are some existing
incompatibilities that prevent usage of OrientDB's remote engine.
This is the only one that allows multiple connections to a db as well
as the built-in clustering capabilities.  It is being worked on to my
understanding and will work in the future.

With regards to bulbs, it is really cool stuff but so abstract that
you cannot take advantage of many of OrientDB specific features.
Namely, schema, indicies work differently, possibly others I cannot
think of.  I love the whole Tinkerpop stack and Rexster/bulbs, will
definitely use them, but not sure if it's a clean fit for an OrientDB
-- web2py specific adapter.  The concept of being able to use bulbs
for all of those datastores would bring even more flexibility so it's
rather appealing in that sense.

-David

On Sep 3, 7:16 pm, Vasile Ermicioi elff...@gmail.com wrote:
 what do you think if we will write and adapter on top of rexter (or
 bulbflow)? we will have an adapter for all rexster graph databases
 (TinkerGraph, Neo4j, OrientDB, DEX, and Sail RDF Stores)

 http://code.google.com/p/orient/wiki/ProgrammingLanguageBindings#Lang...https://github.com/tinkerpop/rexster/wikihttp://bulbflow.com/


[web2py] File renaming

2011-09-01 Thread TheSweetlink
Please tell me where in the source code I can find out how web2py
renames files to prevent directory traversal attacks.

I want to emulate upload field behaviour of renaming the file and
saving it to uploads dir with a reference to it in a currently
unsupported DB.

Thank you

-David


[web2py] Re: File renaming

2011-09-01 Thread TheSweetlink
Yes that is precisely what I was searching for.

Thank you for your turbo reply pbreit.

On Sep 1, 2:44 pm, pbreit pbreitenb...@gmail.com wrote:
 Is this it?http://code.google.com/p/web2py/source/browse/gluon/dal.py#5329


[web2py] Has anyone heard of OrientDB? +1 more question

2011-08-31 Thread TheSweetlink
I would like to build an interface between web2py and OrientDB.  It's
a NOSQL document-graph database with some astonishing features.  See
http://www.orientechnologies.com for full details.

I have been communicating between the two via the requests python lib
and OrientDB's RESTful interface.  The really cool part is that it
uses SQL syntax so it could be a great fit for web2py.

A professionally done interface between the two (intended to be
released as a web2py plugin) would bring a great deal of power to
web2py's already ample capabilities.

As I understand it, and please forgive any ignorance on my part, a
class in a module should do the trick.  Then import the module
whenever communication is needed between web2py and OrientDB.  This
would allow me to keep everything related to communication between the
two in one convenient place.  Error handling and such in one place
should clean up a lot of my code.

As a relative newcomer to web2py I would appreciate any guidance as to
the best approach to go about building such an interface so as to
avoid making a noob-tastic mistake and have to do it all over again.

More specifically, what do you think would be the best approach to
adapt a RESTful OrientDB server to DAL's awesomeness?  Security is a
large concern of mine and DAL's auto-escaping of input plus everything
else it does would bring me peace of mind.

Thank you in advance for your help and time.

-David Bloom


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-08-31 Thread TheSweetlink
Thanks for your quick reply Vasile.  I am truly impressed with this
community.

There are some interesting comparisons between MongoDB and OrientDB.
I chose Orient for my project because of the graph capabilities on top
of its document capabilities.

The mongo adapter is probably a good starting point and thank you for
your willingness to test/contribute.

Another question, do you know how web2py does the renaming/uploading
of files?  I'm trying to determine which would be the best approach
between:

1) Use binary and store images/videos directly in OrientDB

2) Use mysql/postgres to store images because web2py already handles
renaming and uploading of file, then reference it from OrientDB.

I'll post here as soon as I have an update on the adapter's progress.

-David Bloom


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-08-31 Thread TheSweetlink
Strangely I didn't even consider using strictly OrientDB as up until
now I have been using mysql or postgres for login/profile actions and
OrientDB for the rest.  It would be wonderful to use OrientDB for the
entire application.

Storing on disk would be nice for me but OrientDB has a binary type
field that I think would convert it to a base64 string.  How does
web2py do the renaming and other security things to an upload field?

Redarding development I am interested and open to collaborating but
first must check with my counsel as this is for a project which only I
can develop for.
Ideally, we could collaborate on this and give the community another
DB choice in the web2py realm.

Thank you again Vasile for your smart, speedy responses and
enthusiasm.

-David Bloom


On Aug 31, 4:10 pm, Vasile Ermicioi elff...@gmail.com wrote:
 if you/we write the adapter, it should work the same way as other adapters

 that means you have 2 options:
 - you can store file on disk
 - you can store the file on another field (of type blob) in the same table

 no need for other database


[web2py] Re: Has anyone heard of OrientDB? +1 more question

2011-08-31 Thread TheSweetlink
I have not run OrientDB in production but spent the last month
converting my application from mysql -- Orient.  I know that Luca
Garulli has been developing this since 1999 or '97 or so and that it's
made available under the Apache 2.0 license.

He has personally responded quite helpfully to my questions as well as
many others very promptly on several occaisons.

With regards to performance OrientDB is supposedly an absolute
monster.  Their benchmarks had a single server storing 150,000 -
200,000 per second on a modest server!
This is because the graph part of the database eliminates the need for
JOINS to relate your data.  The relation is directly attatched to
whatever it is you are relating to something else.

My experience testing on a very small scale during my app. conversion
has shown OrientDB pulling data I need in 1-7 milliseconds where mysql
took about 80-90.

Combined with Gremlin the graph traversal language, the SQL syntax of
OrientDB + Gremlin allows powerful analysis of your data.

As more performance comparisons become available I will post them.

-David Bloom


On Aug 31, 4:11 pm, Vasile Ermicioi elff...@gmail.com wrote:
 btw, did you test orientdb in production, or at least some performance tests
 against other databases?


[web2py] Re: Please help re: form submission

2011-08-23 Thread TheSweetlink
Anthony you are the man.  That is precisely what I needed to get on my
way.

This post in particular was roughly what I followed to accomplish what
I wanted to do.

http://forum.jquery.com/topic/submit-event-serialize-and-submit-buttons-get-the-button-name

For anyone else reading this it is worth noting that one should be
certain not to call the button action as that will mess with the
form submission.

Thanks again.  I love this community.

-David Bloom


On Aug 22, 10:15 pm, Anthony abasta...@gmail.com wrote:
 The way Ajax form submissions are being done with jQuery, the value of the
 submit button does not get sent with the post data. 
 Seehttps://groups.google.com/d/msg/web2py/708hxAdDGKY/2bNwbQVXc04Jfor more
 details (and possible workaround).

 Anthony


[web2py] Please help re: form submission

2011-08-22 Thread TheSweetlink
I have a custom form for a SQLFORM.factory.

The form has two buttons:

button type=submit name=action value=action1/button
button type=submit name=action value=action2/button

Clicking either button will submit the form and request.vars will have
the correct value.

This works great until I try to LOAD my form as a component.
I was able to find out that when I LOAD my form, request.vars no
longer contains action as it used to upon clicking either action
button.

What can I do to have the above buttons function similarly in a LOADed
component?

Thank you in advance for your help.

-David Bloom


[web2py] Re: Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-20 Thread TheSweetlink
Nevermind.  Got it.

There was a mismatch in # of fields between SQLFORM.factory and my
custom form in the view.

This caused the form to have errors rather than being accepted.

I will be more careful in the future with my custom forms.

Thank you Richard for your help.

-David


[web2py] Re: celery integration?

2011-08-19 Thread TheSweetlink
Check, did that too as it comes before the line that gives me an error
in ABOUT's instructions.

Following ABOUT went swimmingly up until running celerybeat.

rabbitmq-server broker ready, celeryd is ready, but I can't seem to
run that celerybeat command.


On Aug 19, 4:07 am, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 Can you try set

 export WEB2PY_PATH=/path/to/web2py

 On Aug 18, 8:01 pm, TheSweetlink yanosh...@gmail.com wrote:



  Yes sir I did that.

  celeryd --loglevel=DEBUG -E
  runs just fine but

  celerybeat -S scheduler.Web2pyScheduler --loglevel=DEBUG
  does not for me.  Error posted above.

  On Aug 18, 8:30 pm, Massimo Di Pierro massimo.dipie...@gmail.com
  wrote:

   You must run it from the applications/app/modules/plugin_celery folder


[web2py] Re: Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-19 Thread TheSweetlink
Upon further investigation I looked at validators.py to make sure I
was passing IS_IN_SET() the data it is looking for.

A list of tuples should be no problem.  I suspect it must be either
the '#' or the ':' that's the problem.

1) Am I correct in assuming that it shouldn't matter if everything in
my list of tuples are strings?

I also tried passing a list of dicts to IS_IN_SET() and get the same
LazyT 'value not allowed' error.

2) How can I pass the following to IS_IN_SET?

data = [ ('#2:7', 'Sir Gallahad'), ('#3:3', 'Lancealot'), ('#5:6',
'Sir Robin') ]

form = SQLFORM.factory(Field('monty', requires=IS_IN_SET(data))
if form.accepts...
actually accept data and do something, anything
elif form.errors:
response.flash = repr(form.errors)

I would greatly appreciate it if anyone could point me in the right
direction.  Thank you in advance for your time.

-David


[web2py] Re: Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-19 Thread TheSweetlink
Please excuse my typo. I passed one dict as the validator expects
rather than a list of dicts.

 I also tried passing a list of dicts to IS_IN_SET() and get the same
 LazyT 'value not allowed' error.



[web2py] Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-18 Thread TheSweetlink
I am trying to use IS_IN_SET() in a 1 field SQLFORM.factory().

IS_IN_SET() is receiving a list of tuples like:
(['#8:5', 'Bob'), ('#4:2', 'Jane'), ... ]

The set shows up just fine as an dropdown select box but form.errors
shows:
 Storage: {'my_input_name': Lazy T 'value not allowed'} 

I tried to place T.force(None) in models and top of controller but
wish to avoid such a solution as my project will be internationalized
not long after launch.

I would greatly appreciate it if anyone could point me in the right
direction.

Thanks in advance for your time.

-David


[web2py] Re: Issue with SQLFORM.factory() and IS_IN_SET()

2011-08-18 Thread TheSweetlink
Not sure if my post made it so I apologize if I am reposting.  I will
not make any more attempts to post the text below:

Thanks for the quick reply Richard.

The bizarre thing is that I'm not passing anything to T in my code.

I am passing as an example:

sorted_stuff = [ ('#3:4', 'Monty'), ('#6:1', 'Python'), ('#8:8',
'isfunny') ]

form = SQLFORM.factory(Field('parrot',
requires=IS_IN_SET(sorted_stuff))
if form.accepts...

elif form.errors:
response.flash = repr(form.errors)

Again, everything displays correctly and using the new toolbar I can
see that my values are in form.post_vars yet I get the error for Lazy
T.

How can I ask Lazy T to go away for this block of code?

Thanks again for your help,
David


[web2py] Re: celery integration?

2011-08-18 Thread TheSweetlink
Massimo,

I tried to test web2py-celery but was only able to reach the step
where you run celeryd --loglevel=DEBUG -E

When I try to run:
celerybeat -S scheduler.Web2pyScheduler --loglevel=DEBUG

from the appname/modules/plugin_celery dir I get this error:

Pasted for viewability:
http://paste.pocoo.org/show/460537/

I see the Web2pyScheduler class in scheduler.py but for some reason
that command isn't the ticket for me.

Test environment

web2py Version 1.98.2
Nginx 1.04
uWSGI 0.9.8
CentOS 6 in a VirtualBox VM

---

Please advise.

-David


[web2py] Re: celery integration?

2011-08-18 Thread TheSweetlink
Yes sir I did that.

celeryd --loglevel=DEBUG -E
runs just fine but

celerybeat -S scheduler.Web2pyScheduler --loglevel=DEBUG
does not for me.  Error posted above.


On Aug 18, 8:30 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 You must run it from the applications/app/modules/plugin_celery folder



[web2py] Re: IMPORTANT on cron jobs, scheduled jobs and delayed jobs

2011-08-12 Thread TheSweetlink
Long time lurker here.  First, thank you all for this incredible
product and community.  I have learned a great deal in a very short
order of time thanks to web2py and this mailing list.

I may have the opportunity to finally contribute back meaningfully.

Regarding background message/task queuing I have had great success
with a very simple combination that has many extra side benefits.  All
dependencies (BSON, redis-py, hotqueue) are available via pip for easy
installation.  Some pros and cons listed below.

The short version:
Serialize your task/message into a dict, list of dicts, whatever via
BSON (Binary JSON = FAST),
push it to a queue kept in Redis,
background worker pulls from queue and processes it/inserts into db/
whatever you like.

Not only messages but I have successfully tested this as a queue for
tasks as well.  Use a k,v pair in a dict describing your {'action':
'data'}.  It's easy to get creative with it.

Cons:
- More dependencies if you don't already run Redis.
- Time to familiarize yourself with Redis.  (15 - 20 minutes maybe)
- No scheduling built-in but uwsgi decorators can provide cron
capabilities for those running uwsgi.  I haven't played with them yet
but intend to over the next month or two.

Benefits:
- Still fewer dependencies than celery.  Redis becomes the task/
message queue as well as the back end storage and web2py workers
process them.
- Multiple dbs in Redis can be organized into different queues.
- Flexible - Can be adapted to your project fairly easily.
- Also can act as a cache.  Redis has some really useful data types
which you can use to do a lot of your processing in memory.
- Has a pub/sub system which can also be incorporated into your
queue.  Perhaps as a central logging server.
- All data in Redis is kept in memory but persisted to disk = blazing
fast performance with durability.
- Possible simplified application architecture if you use Redis for
your task queue, async message/db insert queue, pub/sub system

I will be happy to create a slice detailing the process with some
abstract examples if anyone has interest in my solution.

Thanks again for all your work.  I intend to contribute back to web2py
as much as I can and all open source because I have learned and built
so much with it.

-David Bloom


[web2py] Re: celery integration?

2011-08-12 Thread TheSweetlink
Hello Massimo,

I do not have any code I can share at the moment for this solution as
I am using it in my current project but I will be very happy to make a
detailed example tomorrow to share with the community.  Do you have
any particular focus in mind?  Async insert into db?  What level of
detail should I provide?  Absolute novice or an assumption of web2py
knowledge?

-David


[web2py] Re: celery integration?

2011-08-12 Thread TheSweetlink
I did set it up for async insert into db to handle traffic spikes if
for example a bunch of people show up and start messaging.

I haven't used it for an e-mail queue yet but that is on my list of
things to do.

Once complete I will post a working e-mail queue solution.

It sounds like Massimo's web2py-celery is much more feature-full and
better suited for task queueing because of the scheduler.

-David

On Aug 12, 2:45 am, pbreit pbreitenb...@gmail.com wrote:
 Maybe sending an email instead of DB insert? Is async DB insert common?


[web2py] Re: celery integration?

2011-08-12 Thread TheSweetlink
Massimo,

I didn't realize that there were other efforts to integrate celery
with web2py aside from yours or that yours was completed already.  I
only offered mine up as a possible easy alternative for those who want
queuing or async insert into db to smooth out traffic spikes.  If it
can be of use I will happily create an abstract example in a web2py
slice or provide the info however is most useful to the community.

For clarification, my solution is separate from all others discussed.
It won't provide scheduling of any kind as is but will provide a way
for people to use Redis and HotQueue as a method to queue tasks to be
completed or to asynchronously insert into a db of users choice.

It is hack-y in the sense that it uses what was intended to be just a
message queue creatively to queue tasks.  The tasks I have set up are
no more than a BSON-serialized dict containing {'action': 'data'}.  It
leaves a great deal of room to be creative and adapt to your
application as you can organize the data and process the queue however
you wish.

It is simpler to implement and has fewer dependencies than celery with
web2py as well as several side-benefits.  These include but are not
limited to: using the same system as for queuing/caching/pub/sub/
ranking/?, useful data-types and more.

-David


On Aug 12, 3:20 pm, Massimo Di Pierro massimo.dipie...@gmail.com
wrote:
 I am a bit confused.

 Are you talking about plugin_celery (http://code.google.com/p/web2py-celery/) 
 or about gluon/scheduler.py They are not the same thing.

 Massimo