[web2py] embedding web2py forms in static websites

2012-02-13 Thread Richard Penman
I want to embed web2py forms in a static website (same domain) and keep the 
static part as simple as possible.

Currently I have this in the static website:
div id=form/div
script 
type=text/javascript$(#form).load(path/to/web2py/app);/script


And this in the web2py app:
def email():
script = 
$(#contact_form).submit(function(event) {
$.post(this.action, $(this).serialize(), function(response) {
$(#contact_form).replaceWith(response);
});
return false;
});

form = FORM(
SCRIPT(script),
TABLE(
TR('Message:', TEXTAREA(_name='message', 
requires=IS_NOT_EMPTY())),
TR('', INPUT(_type='submit')),
), 
_action=URL(), 
_id='contact_form'
)
if form.accepts(request):
# process result ...
return 'Message received'
else:
return form.xml()


The key part is: $(#contact_form).replaceWith(response);
Each AJAX request the form is replaced with the latest response, which is 
either a form with errors or the success message.

This works as expected, but is there a better way to do this? 

Richard


[web2py] Re: SQLFORM.smartgrid links to reference field

2012-02-13 Thread Roderick
bump... anybody?


[web2py] Re: Multiple different problems - Dealing with Integrity Error for nutnull=True and unique=True database fields

2012-02-13 Thread Rahul
Hi All,
   I am using the below statement to serialize images in my view
-
{{=TAG.img(_width=25, _height=30, _src=URL(r=request, c='default',
f='download', args=[adminupdate.profile_pic]))}}

What could I do to make the browser keep the images in cache?

Regards, Rahul D


On Feb 13, 11:13 am, Rahul rahul.dhak...@gmail.com wrote:
 Sorry ... I accidently clicked on Report Span link.. How do I revert
 this?

 On Feb 13, 4:35 am, pbreit pbreitenb...@gmail.com wrote:







  I suggest, if possible, using auth_user as the user table. You can easily
  add fields:http://web2py.com/books/default/chapter/29/9#Customizing-Auth


[web2py] redirect doesn't redirect.

2012-02-13 Thread Annet
I am working on a network app, in which I use the same controllers and
views for all hubs. To keep them separated all hubs have an id and
every hub function start with test_hub_vars:

def test_hub_vars():
if not len(request.args):
redirect(URL('default','error'))
elif request.args(0)==1:
redirect(URL('default','index'))
else:
if not (session.hubnetworkID and session.hubword and
session.hubcontroller_menu):
init_hubvars(request.args(0))
elif session.hubnetworkID != request.args(0):
init_hubvars(request.args(0))


def init_hubvars(networkID):
session.hubnetworkID=networkID
 
row=db(db.NetworkKeyword.networkID==request.args(0)).select(db.NetworkKeyword.word).first()
if row:
session.hubkeyword=row.word
else:
redirect(URL('default','error'))
session.hub_header_top=URL('static','init/images/hub/
hub_header_top.jpg')

This almost works. The exception is the redirect to the default index
function in this case:

http://127.0.0.1:8000/init/hubaddressbook/index/1

the test_hub_vars function should redirect to 
http://127.0.0.1:8000/init/default/index
which it doesn't do. I cannot figure out why this doesn't work.

Kind regards,

Annet


Re: [web2py] redirect doesn't redirect.

2012-02-13 Thread Ricardo Pedroso
On Mon, Feb 13, 2012 at 10:58 AM, Annet anneve...@googlemail.com wrote:

    elif request.args(0)==1:

This one above is always False. Should be at least:

elif request.args(0)==1:

request.args returns each arg as string.

Ricardo


[web2py] One time action for user

2012-02-13 Thread Hassan Alnatour
Dear All,

i have a polls application and there is no registration but i want the
user to vote only one time , how can i do that ?


Re: [web2py] New Plugin: plugin_markitup

2012-02-13 Thread Marin Pranjić
Thanks, i will test by the end of the week.
I need this.

Marin

On Sun, Feb 12, 2012 at 10:07 PM, Ross Peoples ross.peop...@gmail.comwrote:

 I have created another plugin for the MarkItUp widget. I know that
 plugin_wiki has this currently, but I wanted a dedicated plugin for this
 for an upcoming project I'm working on.

 You can get the plugin from Bitbucket:
 https://bitbucket.org/PhreeStyle/web2py_markitup

 There is no documentation yet, as I just pushed the code. But I wanted to
 announce in case anyone wants to play with this. It has not been thoroughly
 tested and is only an alpha at this point. It can be used with several
 different markup languages:

- BBCode
- HTML
- Markdown
- Markmin
- reStructuredText
- Textile
- Wiki

 The plugin can be used standalone, or as a form field widget. It currently
 supports live previews for 4 markup languages: html, markmin, markdown,
 textile, and bbcode. Code blocks for markmin and markdown markup are
 highlighted by pygments, which is included as part of the plugin. No
 external dependencies. Using pygments for code highlighting allows over 100
 languages to be highlighted.

 Code highlighting in markmin:

 ``
 def testing():
 print 'Testing'
 ``:python

 Code highlighting in markdown:

 :::python
 def testing():
 print 'Testing'

 Markdown requires four spaces at the beginning of each line for code
 blocks.

 Example for basic usage:

 from plugin_markitup.markitup import MarkItUp

 def test():
 widget = MarkItUp(set_name='markmin').markitup()
 return dict(widget=widget)


 Example model for form fields:

 from plugin_markitup.markitup import MarkItUp

 db.define_table('content',
 Field('name', length=20),
 Field('description', 'text')
 )
 db.content.description.widget = MarkItUp().widget


 Example controller:
 def test():
 form = SQLFORM(db.content)
 if form.accepts(request, session):
 redirect(URL())

 return dict(form=form)


 This plugin is more of an alpha preview, so I expect there to be problems
 and inconsistencies. Please try it out and let me know if you have any
 questions, comments, or problems!



[web2py] Re: One time action for user

2012-02-13 Thread Anthony
This isn't foolproof, but upon voting, you can send a cookie to the user's 
browser. Before allowing a user to vote, check for the cookie, and if it 
exists, don't allow the vote. Note, this will only prevent someone from 
voting twice from the same machine and browser, assuming they don't delete 
the cookie. If someone attempts to vote multiple times, you might not want 
to notify them that the subsequent votes don't count -- in that case, they 
may catch on and figure out how to vote multiple times by deleting the 
cookie or switching browsers.

See http://web2py.com/books/default/chapter/29/4#Cookies.

Anthony

On Monday, February 13, 2012 9:19:03 AM UTC-5, Hassan Alnatour wrote:

 Dear All, 

 i have a polls application and there is no registration but i want the 
 user to vote only one time , how can i do that ?



[web2py] Re: redirect doesn't redirect.

2012-02-13 Thread Annet
Hi Ricardo,

Thanks for your reply, changing 1 to 1 solved the problem.


Kind regards,

Annet

On Feb 13, 12:47 pm, Ricardo Pedroso rmdpedr...@gmail.com wrote:
 On Mon, Feb 13, 2012 at 10:58 AM, Annet anneve...@googlemail.com wrote:
     elif request.args(0)==1:

 This one above is always False. Should be at least:

 elif request.args(0)==1:

 request.args returns each arg as string.

 Ricardo


[web2py] Re: One time action for user

2012-02-13 Thread Hassan Alnatour
Dear Anthony ,

Thnx it works :)


[web2py] Re: web2py shell not executing db.define_table() but does record it in SQL log.

2012-02-13 Thread Bill Thayer
No luck there either. Tried twice:

In [2] : print db.tables
['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
'auth_event', 'auth_cas', 'image', 'comment']

In [3] : print db.tables
['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
'auth_event', 'auth_cas', 'image', 'comment']




[web2py] Problem with update

2012-02-13 Thread pbreit
Shouldn't be he problem but I see at leat one typo: resposne.session_id

Can you try setting session_id to 0?

Why are you doing this?


[web2py] Re: Routes.py and janrain login

2012-02-13 Thread Rene Dohmen
Got it working with the example from the web2py book:

routers = dict(
  BASE  = dict(default_application='formatics'),
)

Thank you web2py book :)

Maybe a nice reminder for people running with mod_wsgi: you have to
restart the webserver to activate changes in routes.py, and that's why
it didn't work the 1st time

R

On Feb 2, 2:51 am, Rene Dohmen acidj...@gmail.com wrote:
 Hi List,

 I've installed mod_wsgi on our server and added a vhost so that each
 application is accessible viawww.examples.com/app_name

 One of the apps is ready; so I created another vhost and started an
 separate instance of web2py.
 The second instance uses a routes.py to remove the appname from the
 URL.

 You can see it here:http://www.formaticz.nl

 Everything works OK, but when I try to login via the janrain login, I
 get redirected to:http://www.formaticz.nl/formatics/default/user/logininstead 
 ofhttp://www.formaticz.nl/default/user/login
 (making it impossible to login)

 This is the routes.py I used (in root web2py folder).

 routes_in=[['/$anything','/formatics/$anything']]
 routes_out=[['/formatics/$anything','/$anything']]

 I tried adding some extra values to it, but couldn't get it working.

 Kind Regards,Rene


Re: [web2py] Problem with update

2012-02-13 Thread Richard Vézina
You should replace IS_NULL_OR by IS_EMPTY_OR, IS_NULL_OR is depricated if I
remember.

I don't see what could be wrong... But I read recently about test that
could be conflicting with web2py some how...

But I guest that you try to implement a home made solution to follow logged
on and logged off user... I think you should have a look to comet server a
contrib to web2py that is supposed to allow tracking connection to app.
Nerver used until now...

Richard

On Mon, Feb 13, 2012 at 2:48 AM, weheh richard_gor...@verizon.net wrote:

 I'm running Version 1.99.2.

 # model
 db.define_table('test',

 Field('user_id',db.auth_user,requires=IS_NULL_OR(IS_IN_DB(db,'auth_user.id
 '))),
  Field('session_id',default=resposne.session_id),
 ...
 )


 # at some point, the following would be executed:

 test_id=db.test.insert(
  user_id=auth.user.id if auth.is_logged_in() else None,
 )


 # in the index controller there is the following test condition
 def index():
 ...
if auth.is_logged_in():
db((db.test.user_id==None) 
 (db.test.session_id==response.session_id)).update(user_id=auth.user.id
 ,session_id=None)

 ...

 Here's the problem. db.test.user_id is getting properly updated to the
 logged in auth.user.id. However, session_id is not getting set to
 None. Anybody see what I could be doing wrong?



[web2py] Re: web2py shell not executing db.define_table() but does record it in SQL log.

2012-02-13 Thread Anthony
Are you using the web-based shell in the admin app, or a regular Python 
shell? You might try a regular shell, as the web-based shell seems to have 
some limitations.

Anthony

On Monday, February 13, 2012 11:13:41 AM UTC-5, Bill Thayer wrote:

 No luck there either. Tried twice:

 In [2] : print db.tables
 ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
 'auth_event', 'auth_cas', 'image', 'comment']

 In [3] : print db.tables
 ['auth_user', 'auth_group', 'auth_membership', 'auth_permission', 
 'auth_event', 'auth_cas', 'image', 'comment']




[web2py] Can this be improved?

2012-02-13 Thread pbreit
I think list comprehensins are reasonable way to populate drop-downs.

You don't need to specify he select fields if you dont want to. Then you'll 
just gt back ALL fields.

Naming the db db is much easier to read for us.


Re: [web2py] Re: Multiple different problems - Dealing with Integrity Error for nutnull=True and unique=True database fields

2012-02-13 Thread Niphlod
that caches something into web2py, not into browser.

To cache into browser, probably the most rapid way is to send out expire 
headers in the future.

something like this would cache the file into browser for 30 days


You are using the default download function, so if you need this 
functionality you must add these lines to that function

def download():

allows downloading of uploaded files
http:///[app]/default/download/[filename]

import datetime
response.headers['Cache-Control'] = 'public'
response.headers['Expires'] = datetime.datetime.strftime(request.utcnow 
+ datetime.timedelta(days=30), '%a, %d %b %Y %H:%M:%S GMT')

return response.download(request,db)




[web2py] Current status of adapting OrientDB for web2py

2012-02-13 Thread Nolan Nichols
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: Dedicated IDE

2012-02-13 Thread Lewis
Happily using Komodo Edit 6.  If web2py is in the pythonpath, you get
autocomplete for it as well as the rest of python.   I find it handier
than using any of the dedicated python ide's because you also must
work on html views and css files.  It has autocomplete, syntax
checking, and brace matching for all 3 languages (and many more).  It
has built-in sftp support so editing web2py files on my site is almost
local.  I haven't figured out projects yet.  I haven't seen the need
for Komodo IDE, which must do a lot of additional magic for its price
($299 I think ??).

On Feb 12, 10:32 pm, Rahul rahul.dhak...@gmail.com wrote:
 +1 for Aptana, Eclipse (my personal favorite for all languages) and
 ide2py/read2py - looks promising too.

 Rahul D

 On Feb 13, 6:00 am, Jim Steil j...@qlf.com wrote:







  I'm an Aptana user.  Works great for me.

       -Jim

  On 2/12/2012 6:08 PM, Bruce Wade wrote:

   IDE's are good when you are working on large projects, and or
   on medium to large teams. Also by dedicated IDE I mean more then just
   typing text. Think more like an environment that can handle all your
   planing tasks, profiling, design layouts etc but in more of a
   visual way.

   I am all for vim when I want to do something with a single file
   however when I am going to be coding all day it becomes a pain to
   always have to type commands just to edit text etc..

   I also come from a background of game development so I kind of prefer
   the custom tools that are developed for making them kinds of projects.

   On Sun, Feb 12, 2012 at 3:04 PM, pbreit pbreitenb...@gmail.com
   mailto:pbreitenb...@gmail.com wrote:

       You should not be using the web-based editor for anything beyond
       quick edits or testing,

       I always steer people away from IDEs and to just use a good text
       editor (for Mac, TextMate) and version control (I like MacHG
       better than SourceTree).

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

   No virus found in this message.
   Checked by AVG -www.avg.comhttp://www.avg.com
   Version: 2012.0.1913 / Virus Database: 2112/4806 - Release Date: 02/12/12

  --
  Jim Steil
  VP of Information Technology
  Quality Liquid Feeds, Inc.
  608.935.2345 office
  608.341.9896 cell


[web2py] Calling remote program on DB2 from Python/Web2py

2012-02-13 Thread Omi Chiba
Posted on web2py slice.
http://www.web2pyslices.com/slices/take_slice/151

I'm so excited and it is greater than aha moment for me. We're using
DB2 for our internal web app and now I can do almost anything from
web2py because RPG/CL/Query... will be dynamically executed from
web2py as an part of process.

If you use DB2, I strongly recommend to try !


Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1

2012-02-13 Thread Wikus van de Merwe
LGPL is designed for libraries. Static or dynamic linking to LGPL code is 
allowed without enforcing copy-left. That means that the derivative work 
can even be a proprietary software. However, if you change the library code 
itself, you modification has to be released under LGPL. Since version 3 
LGPL is compatible with GPL, which means that the modifications could be 
released under GPLv3 too.

In case of CMS, all these doesn't matter in practice. CMS is not a 
self-contained isolated library and except of very simple projects, a web 
application build on top of it will require changes in the CMS code. So 
commonly, there would be the same copy-left enforcement in place as in case 
of the GPL. There is also no difference between GPL and LGPL with respect 
to the server deployment. Both licenses do not see that as distribution, so 
the deployed code, whatever type of changes it contains, can remain secret. 
That's why my recommendation was GPLv3, as in this case there is no way to 
get anything extra from LGPL anyway.

I guess the key difference is in the licenses compatibility. Under LGPLv3 
you can include all non copy-left free software (BSD, MIT, MPL 2.0, Apache 
2.0) but not the code under the GPL (you would have to release the 
combination under GPLv3, for details see the compatibility matrix [1]). 
With GPLv3 it's simpler as more licenses are compatible (see the full list 
[2]), including GPLv2 as long as the phrase either version 2 of the 
License, or (at your option) any later version is present in the copyright 
notice.

For more arguments in the GPL vs LGPL case see [3].

[1] http://www.gnu.org/licenses/gpl-faq.html#AllCompatibility
[2] http://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses
[3] http://www.gnu.org/licenses/why-not-lgpl.html


[web2py] How to keep plugins up-to-date across apps

2012-02-13 Thread monotasker
I'm using a lot of custom plugins to allow re-use of code across several of 
my web2py apps. But since the plugins are in a state of constant updating, 
it's getting to be a pain to keep them all in sync. I use git for version 
control (one repo for each app) and for deployment (on Fluxflex). I've 
considered trying to use git submodules, but have found them a bit 
confusing (in the little time I've spent looking at them). The overall 
problem seems to be exacerbated by the fact that a plugin's files are 
spread out across the app's file structure. Any suggestions?

Thanks,

Ian


Re: [web2py] How to keep plugins up-to-date across apps

2012-02-13 Thread Richard Vézina
I never try it... But since web2py like linux and unix everything is in a
file somewhere, you maybe could try to make use of symbolic links... So you
could have a app (plugin app) that is linked as a plugin in others app
(main app that rely on some plugins).

Really not sure how well it could work.

If you try something, I would be interested if you report the problems you
face and how you walk around.

Richard



On Mon, Feb 13, 2012 at 3:58 PM, monotasker scotti...@gmail.com wrote:

 I'm using a lot of custom plugins to allow re-use of code across several
 of my web2py apps. But since the plugins are in a state of constant
 updating, it's getting to be a pain to keep them all in sync. I use git for
 version control (one repo for each app) and for deployment (on Fluxflex).
 I've considered trying to use git submodules, but have found them a bit
 confusing (in the little time I've spent looking at them). The overall
 problem seems to be exacerbated by the fact that a plugin's files are
 spread out across the app's file structure. Any suggestions?

 Thanks,

 Ian



[web2py] Memcache ??

2012-02-13 Thread Hassan Alnatour
Dear ALL,

What is cache and what is memcache ?? i dont understand it ? why we
use it , what happens when we use it !!


Re: [web2py] Possibly bug with insert

2012-02-13 Thread Richard Vézina
I think a bit more of your code controller would be required to understand
what's going on...

Richard

On Mon, Feb 13, 2012 at 4:29 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Hi,

 db.define_table('cash_journal',
 Field('transaction_type'),
 Field('distributor_id', 'integer'),
 Field('happen_time', 'datetime', default=request.now),
 Field('happen_amount', 'decimal(10,2)'),
 Field('ucash_before', 'decimal(10,2)'),
 Field('ucash_after', 'decimal(10,2)'),
 Field('transaction_id', 'integer', default=None),
 Field('operator_id', 'integer', default=0)
 )

 Calling:

db.cash_journal.insert(
 transaction_type = UCashChangeType.buy_product,
 distributor_id = distributor.id,
 happen_amount = -int(payment_amount),
 ucash_before = ucash_before,
 ucash_after = ucash_after,
 transaction_id = payment,
 operator_id = distributor.id
 )

 Gave me:
 Traceback (most recent call last):

   File 
 /home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/restricted.py, 
 line 204, in restricted

 exec ccode in environment

   File 
 /home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/products.py
  http://127.0.0.1:8000/admin/edit/welcome/controllers/products.py, line 
 565, in module

   File 
 /home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/globals.py, 
 line 172, in lambda

 self._caller = lambda f: f()

   File 
 /home/bruce/Development/bossteam_dev/projects/yaw_dev/applications/welcome/controllers/products.py
  http://127.0.0.1:8000/admin/edit/welcome/controllers/products.py, line 
 229, in payment

 operator_id = distributor.id

   File /home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py, 
 line 5597, in insert

 return self._db._adapter.insert(self,self._listify(fields))

   File /home/bruce/Development/bossteam_dev/projects/yaw_dev/gluon/dal.py, 
 line 914, in insert

 raise e

 IntegrityError: duplicate key value violates unique constraint 
 cash_journal_pkey
 DETAIL:  Key (id)=(1) already exists.


 Any reason why insert wouldn't just give you a new ID for primary key?
 --
 --
 Regards,
 Bruce Wade
 http://ca.linkedin.com/in/brucelwade
 http://www.wadecybertech.com
 http://www.warplydesigned.com
 http://www.fitnessfriendsfinder.com



[web2py] Re: Possibly bug with insert

2012-02-13 Thread Ron McOuat
It is like the sequence for that primary key has started over with a reset 
to initial value since the key value that causes the exception is 1. To do 
that I would think you would have to tweak the sequence with psql while 
there is data in the table.

Ron


Re: [web2py] Re: Possibly bug with insert

2012-02-13 Thread Richard Vézina
He could reset the sequence for sure, but maybe his code induce the
increment problem.

Richard

On Mon, Feb 13, 2012 at 4:46 PM, Ron McOuat ron.mco...@gmail.com wrote:

 It is like the sequence for that primary key has started over with a reset
 to initial value since the key value that causes the exception is 1. To do
 that I would think you would have to tweak the sequence with psql while
 there is data in the table.

 Ron



Re: [web2py] Re: Possibly bug with insert

2012-02-13 Thread Bruce Wade
Didn't touch psql. there is 3 records in that table already, so I was not
sure why it would even default to 1.

Here is the code that processes after the form is accepted. My code didn't
increment anything just standard web2py calls.


if ucashmethod.process(formname='ucash').accepted:

1) Check payment amount
2) Check owing amount
3) Make sure payment amount is not greater then owing amount
4) Make sure member has enough ucash to cover the payment amount
5) Complete the order
6) Add to the capital investments
7) Give all the sponsor bonus
8) Redirect to thank you page

if float(ucash_available) =
float(product_details['product_orders'].owing):
print ucash amount is good
payment_amount = product_details['product_orders'].owing
ucash_before = distributor.ucash_balance
distributor.ucash_balance -= int(payment_amount)
distributor.ucash_balance_available -= int(payment_amount)
ucash_after = distributor.ucash_balance

product_details['product_orders'].owing -= int(payment_amount)
product_details['product_orders'].update_record()
distributor.update_record()

payment = db.payments.insert(
order_id = product_details['product_orders'].id,
ack = '',
transactionid = '',
paymentstatus = 'Completed',
pendingreason = 'None',
currencycode = 'USD',
taxamt = '0.00',
paymenttype = 'Youcash',
token = 'N/A',
version = 1,
build = 1,
feeamt = '',
reasoncode = 'None',
amt = payment_amount,
correlationid = 'CORRELATIONID',
transactiontype = 'Youcash'
)

db.cash_journal.insert(
transaction_type = UCashChangeType.buy_product,
distributor_id = distributor.id,
happen_amount = -int(payment_amount),
ucash_before = ucash_before,
ucash_after = ucash_after,
transaction_id = payment,
operator_id = distributor.id
)

if product_details['product_orders'].owing = 0:
# 1) add product, do bonus calculations
x = distributor_engine.addProduct(distributor,
product_details['products'])
buy_time =
distributor_engine.get_valid_buy_times(distributor)

if distributor.id == 1:
# place member as root
#distributor_engine.place_member(None, None, None)

distributor_engine.member_purchase_prod_calc(distributor,
product_details['products'])
elif (db(db.capital_investments.member_id ==
distributor.id).count()
 1 and x != -1) or ((buy_time==0 or buy_time==1) and distributor.upline_id
and distributor.sponsor_id):
print Calculating bonuses


distributor_engine.member_purchase_prod_calc(distributor,
product_details['products'])
else:
session.flash = T(Sorry there is not enough ucash in your
account to complete this purchase!)
redirect(URL('products','payment/%s' % purchase_uuid))

#session.flash = 'Congrats for your new product'
redirect(URL('products','index'))

On Mon, Feb 13, 2012 at 1:46 PM, Ron McOuat ron.mco...@gmail.com wrote:

 It is like the sequence for that primary key has started over with a reset
 to initial value since the key value that causes the exception is 1. To do
 that I would think you would have to tweak the sequence with psql while
 there is data in the table.

 Ron




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


Re: [web2py] Re: Possibly bug with insert

2012-02-13 Thread Richard Vézina
Try db.commit() between your two insert... Maybe web2py is doing only one
commit at the end of your function, but since you do insert by hand instead
of let the form insert your maybe have to commit...

Richard

On Mon, Feb 13, 2012 at 4:51 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Didn't touch psql. there is 3 records in that table already, so I was not
 sure why it would even default to 1.

 Here is the code that processes after the form is accepted. My code didn't
 increment anything just standard web2py calls.

 
 if ucashmethod.process(formname='ucash').accepted:
 
 1) Check payment amount
 2) Check owing amount
 3) Make sure payment amount is not greater then owing amount
 4) Make sure member has enough ucash to cover the payment amount
 5) Complete the order
 6) Add to the capital investments
 7) Give all the sponsor bonus
 8) Redirect to thank you page
 
 if float(ucash_available) =
 float(product_details['product_orders'].owing):
 print ucash amount is good
 payment_amount = product_details['product_orders'].owing
 ucash_before = distributor.ucash_balance
 distributor.ucash_balance -= int(payment_amount)
 distributor.ucash_balance_available -= int(payment_amount)
 ucash_after = distributor.ucash_balance

 product_details['product_orders'].owing -= int(payment_amount)
 product_details['product_orders'].update_record()
 distributor.update_record()

 payment = db.payments.insert(
 order_id = product_details['product_orders'].id,
 ack = '',
 transactionid = '',
 paymentstatus = 'Completed',
 pendingreason = 'None',
 currencycode = 'USD',
 taxamt = '0.00',
 paymenttype = 'Youcash',
 token = 'N/A',
 version = 1,
 build = 1,
 feeamt = '',
 reasoncode = 'None',
 amt = payment_amount,
 correlationid = 'CORRELATIONID',
 transactiontype = 'Youcash'
 )

 db.cash_journal.insert(
 transaction_type = UCashChangeType.buy_product,
 distributor_id = distributor.id,
 happen_amount = -int(payment_amount),
 ucash_before = ucash_before,
 ucash_after = ucash_after,
 transaction_id = payment,
 operator_id = distributor.id
 )

 if product_details['product_orders'].owing = 0:
 # 1) add product, do bonus calculations
 x = distributor_engine.addProduct(distributor,
 product_details['products'])
 buy_time =
 distributor_engine.get_valid_buy_times(distributor)

 if distributor.id == 1:
 # place member as root
 #distributor_engine.place_member(None, None, None)

 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 elif (db(db.capital_investments.member_id ==
 distributor.id).count()  1 and x != -1) or ((buy_time==0 or buy_time==1)
 and distributor.upline_id and distributor.sponsor_id):
 print Calculating bonuses


 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 else:
 session.flash = T(Sorry there is not enough ucash in your
 account to complete this purchase!)
 redirect(URL('products','payment/%s' % purchase_uuid))

 #session.flash = 'Congrats for your new product'
 redirect(URL('products','index'))

 On Mon, Feb 13, 2012 at 1:46 PM, Ron McOuat ron.mco...@gmail.com wrote:

 It is like the sequence for that primary key has started over with a
 reset to initial value since the key value that causes the exception is 1.
 To do that I would think you would have to tweak the sequence with psql
 while there is data in the table.

 Ron




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



Re: [web2py] Calling remote program on DB2 from Python/Web2py

2012-02-13 Thread António Ramos
Excelent
How to pass parameters and receive result?

Thank you
António

2012/2/13 Omi Chiba ochib...@gmail.com

 Posted on web2py slice.
 http://www.web2pyslices.com/slices/take_slice/151

 I'm so excited and it is greater than aha moment for me. We're using
 DB2 for our internal web app and now I can do almost anything from
 web2py because RPG/CL/Query... will be dynamically executed from
 web2py as an part of process.

 If you use DB2, I strongly recommend to try !


[web2py] Is Python 2.5 ok or do I need 2.5.6?

2012-02-13 Thread Bill Thayer
Thanks to everyone for answering my questions so far. 

At the deployment section of the book now. Earlier I've been running web2py 
with python 2.7 but to run from source I need to install 2.5. The python 
web site has an msi installer for 2.5 but only source code for 2.5.6. 
http://www.python.org/getit/releases/2.5.6/NEWS.txt describing the 
differences. the text file is a bit too long to paste here.

Installing on an apache server with mod_wsgi on windows xp 32 bit. Should I 
try to build and install 2.5.6 or will the 2.5 that comes with the msi 
installer be ok?

Regards,
Bill




Re: [web2py] Re: Possibly bug with insert

2012-02-13 Thread Bruce Wade
Yeah I don't think that is the issue because it has worked several times
before, probably a bug in the database I will just rebuild it and try again.

On Mon, Feb 13, 2012 at 2:08 PM, Richard Vézina ml.richard.vez...@gmail.com
 wrote:

 Try db.commit() between your two insert... Maybe web2py is doing only one
 commit at the end of your function, but since you do insert by hand instead
 of let the form insert your maybe have to commit...

 Richard


 On Mon, Feb 13, 2012 at 4:51 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Didn't touch psql. there is 3 records in that table already, so I was not
 sure why it would even default to 1.

 Here is the code that processes after the form is accepted. My code
 didn't increment anything just standard web2py calls.

 
 if ucashmethod.process(formname='ucash').accepted:
 
 1) Check payment amount
 2) Check owing amount
 3) Make sure payment amount is not greater then owing amount
 4) Make sure member has enough ucash to cover the payment amount
 5) Complete the order
 6) Add to the capital investments
 7) Give all the sponsor bonus
 8) Redirect to thank you page
 
 if float(ucash_available) =
 float(product_details['product_orders'].owing):
 print ucash amount is good
 payment_amount = product_details['product_orders'].owing
 ucash_before = distributor.ucash_balance
 distributor.ucash_balance -= int(payment_amount)
 distributor.ucash_balance_available -= int(payment_amount)
 ucash_after = distributor.ucash_balance

 product_details['product_orders'].owing -= int(payment_amount)
 product_details['product_orders'].update_record()
 distributor.update_record()

 payment = db.payments.insert(
 order_id = product_details['product_orders'].id,
 ack = '',
 transactionid = '',
 paymentstatus = 'Completed',
 pendingreason = 'None',
 currencycode = 'USD',
 taxamt = '0.00',
 paymenttype = 'Youcash',
 token = 'N/A',
 version = 1,
 build = 1,
 feeamt = '',
 reasoncode = 'None',
 amt = payment_amount,
 correlationid = 'CORRELATIONID',
 transactiontype = 'Youcash'
 )

 db.cash_journal.insert(
 transaction_type = UCashChangeType.buy_product,
 distributor_id = distributor.id,
 happen_amount = -int(payment_amount),
  ucash_before = ucash_before,
 ucash_after = ucash_after,
 transaction_id = payment,
 operator_id = distributor.id
 )

 if product_details['product_orders'].owing = 0:
 # 1) add product, do bonus calculations
 x = distributor_engine.addProduct(distributor,
 product_details['products'])
 buy_time =
 distributor_engine.get_valid_buy_times(distributor)

 if distributor.id == 1:
 # place member as root
 #distributor_engine.place_member(None, None, None)

 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 elif (db(db.capital_investments.member_id ==
 distributor.id).count()  1 and x != -1) or ((buy_time==0 or
 buy_time==1) and distributor.upline_id and distributor.sponsor_id):
 print Calculating bonuses


 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 else:
 session.flash = T(Sorry there is not enough ucash in your
 account to complete this purchase!)
 redirect(URL('products','payment/%s' % purchase_uuid))

 #session.flash = 'Congrats for your new product'
 redirect(URL('products','index'))

 On Mon, Feb 13, 2012 at 1:46 PM, Ron McOuat ron.mco...@gmail.com wrote:

 It is like the sequence for that primary key has started over with a
 reset to initial value since the key value that causes the exception is 1.
 To do that I would think you would have to tweak the sequence with psql
 while there is data in the table.

 Ron




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





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


[web2py] CSV Import performance improvement idea

2012-02-13 Thread Omi Chiba
I have a problem with the performance of CSV import and I assume it
generate INSERT statement for every record so it will be 8000
statement if you have 8000 records in csv file.

Can we use bulk_insert method instead so there will be always only one
INSERT statement  which should reduce the performance significantly ?



[web2py] Re: Calling remote program on DB2 from Python/Web2py

2012-02-13 Thread Omi Chiba
I will try tomorrow and let you know. I have RPG to return the price
for the given currency (e.g. USD $100 = EUR $76) so it will be a good
sample.


On Feb 13, 4:13 pm, António Ramos ramstei...@gmail.com wrote:
 Excelent
 How to pass parameters and receive result?

 Thank you
 António

 2012/2/13 Omi Chiba ochib...@gmail.com







  Posted on web2py slice.
 http://www.web2pyslices.com/slices/take_slice/151

  I'm so excited and it is greater than aha moment for me. We're using
  DB2 for our internal web app and now I can do almost anything from
  web2py because RPG/CL/Query... will be dynamically executed from
  web2py as an part of process.

  If you use DB2, I strongly recommend to try !


[web2py] Re: web2py-python3

2012-02-13 Thread Vadim K
Nice port, I would say.

I'll give it a try


[web2py] Conditional deletes (ondelete etc) in sqlform.grid

2012-02-13 Thread Mark Kirkwood
I am attempting to implement a check that allows deletes only under some 
circumstances. I figured I would do this via the ondelete arg in the 
grid. Unfortunately I have run into a few stumbling blocks with this:


1/ The 1.99.4 code is busted - references 'ret' before it is defined

Fortunately a simple fix (I think you guys have done something like this 
in trunk) -


sqlhtml.py:1294
if ondelete:
#ondelete(table,request.args[-1],ret)
ondelete(table,request.args[-1])

2/ The ondelete function is only called from the main grid delete 
action, not the delete checkbox in edit mode


I would be great if the logic could be applied there too - otherwise I 
guess I can workaround by switching the delete option off in the edit 
screen.



3/ Am unclear about how to signal back that I want delete to stop

I figure I am just being dense in this case, but ondelete function 
accepts table and row id variables (not a form) so I don't see any way 
to set the form's error status.


Thanks for your help

Mark


Re: [web2py] Re: web2py-python3

2012-02-13 Thread Bruce Wade
Nice, will there ever be an official web2py on python 3?

On Mon, Feb 13, 2012 at 2:21 PM, Vadim K pubi...@gmail.com wrote:

 Nice port, I would say.

 I'll give it a try




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


Re: [web2py] Re: Possibly bug with insert

2012-02-13 Thread Bruce Wade
Deleting the database looks to have fixed it.

On Mon, Feb 13, 2012 at 2:24 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Yeah I don't think that is the issue because it has worked several times
 before, probably a bug in the database I will just rebuild it and try again.


 On Mon, Feb 13, 2012 at 2:08 PM, Richard Vézina 
 ml.richard.vez...@gmail.com wrote:

 Try db.commit() between your two insert... Maybe web2py is doing only one
 commit at the end of your function, but since you do insert by hand instead
 of let the form insert your maybe have to commit...

 Richard


 On Mon, Feb 13, 2012 at 4:51 PM, Bruce Wade bruce.w...@gmail.com wrote:

 Didn't touch psql. there is 3 records in that table already, so I was
 not sure why it would even default to 1.

 Here is the code that processes after the form is accepted. My code
 didn't increment anything just standard web2py calls.

 
 if ucashmethod.process(formname='ucash').accepted:
 
 1) Check payment amount
 2) Check owing amount
 3) Make sure payment amount is not greater then owing amount
 4) Make sure member has enough ucash to cover the payment amount
 5) Complete the order
 6) Add to the capital investments
 7) Give all the sponsor bonus
 8) Redirect to thank you page
 
 if float(ucash_available) =
 float(product_details['product_orders'].owing):
 print ucash amount is good
 payment_amount = product_details['product_orders'].owing
 ucash_before = distributor.ucash_balance
 distributor.ucash_balance -= int(payment_amount)
 distributor.ucash_balance_available -= int(payment_amount)
 ucash_after = distributor.ucash_balance

 product_details['product_orders'].owing -=
 int(payment_amount)
 product_details['product_orders'].update_record()
 distributor.update_record()

 payment = db.payments.insert(
 order_id = product_details['product_orders'].id,
 ack = '',
 transactionid = '',
 paymentstatus = 'Completed',
 pendingreason = 'None',
 currencycode = 'USD',
 taxamt = '0.00',
 paymenttype = 'Youcash',
 token = 'N/A',
 version = 1,
 build = 1,
 feeamt = '',
 reasoncode = 'None',
 amt = payment_amount,
 correlationid = 'CORRELATIONID',
 transactiontype = 'Youcash'
 )

 db.cash_journal.insert(
 transaction_type = UCashChangeType.buy_product,
 distributor_id = distributor.id,
 happen_amount = -int(payment_amount),
  ucash_before = ucash_before,
 ucash_after = ucash_after,
 transaction_id = payment,
 operator_id = distributor.id
 )

 if product_details['product_orders'].owing = 0:
 # 1) add product, do bonus calculations
 x = distributor_engine.addProduct(distributor,
 product_details['products'])
 buy_time =
 distributor_engine.get_valid_buy_times(distributor)

 if distributor.id == 1:
 # place member as root
 #distributor_engine.place_member(None, None, None)

 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 elif (db(db.capital_investments.member_id ==
 distributor.id).count()  1 and x != -1) or ((buy_time==0 or
 buy_time==1) and distributor.upline_id and distributor.sponsor_id):
 print Calculating bonuses


 distributor_engine.member_purchase_prod_calc(distributor,
 product_details['products'])
 else:
 session.flash = T(Sorry there is not enough ucash in your
 account to complete this purchase!)
 redirect(URL('products','payment/%s' % purchase_uuid))

 #session.flash = 'Congrats for your new product'
 redirect(URL('products','index'))

 On Mon, Feb 13, 2012 at 1:46 PM, Ron McOuat ron.mco...@gmail.comwrote:

 It is like the sequence for that primary key has started over with a
 reset to initial value since the key value that causes the exception is 1.
 To do that I would think you would have to tweak the sequence with psql
 while there is data in the table.

 Ron




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





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




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

[web2py] Re: Is Python 2.5 ok or do I need 2.5.6?

2012-02-13 Thread Anthony


 At the deployment section of the book now. Earlier I've been running 
 web2py with python 2.7 but to run from source I need to install 2.5.


Actually, if you've been running web2py with Python 2.7, then you have been 
running the source version of web2py. The version of web2py that comes with 
its own Python 2.5 interpreter is the binary version (for Windows or Mac), 
not the source version.
 

 The python web site has an msi installer for 2.5 but only source code for 
 2.5.6. http://www.python.org/getit/releases/2.5.6/NEWS.txt describing the 
 differences. the text file is a bit too long to paste here.


If you want to run from source, then you do not need Python 2.5 at all -- 
Python 2.7 is fine. If you want to run the binary version of web2py, you 
don't have to install Python (in fact, even if you do install your own 
Python, it will be ignored and web2py will use its own Python 2.5 
interpreter).

Anthony



Re: [web2py] Re: web2py-python3

2012-02-13 Thread Ovidio Marinho
Do you have tutorial installation.



   Ovidio Marinho Falcao Neto
Web Developer
 ovidio...@gmail.com
  ovidiomari...@itjp.net.br
 ITJP - itjp.net.br
   83   8826 9088 - Oi
   83   9334 0266 - Claro
Brasil




2012/2/14 Bruce Wade bruce.w...@gmail.com

 Nice, will there ever be an official web2py on python 3?


 On Mon, Feb 13, 2012 at 2:21 PM, Vadim K pubi...@gmail.com wrote:

 Nice port, I would say.

 I'll give it a try




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



[web2py] Re: Implementing task queue using web2py

2012-02-13 Thread Saurabh S
It worked when I passed a different controller in the url other than
the one it is being called from.

It is production.
I checked the task queue it simply retries continuously if the same
controller is provided.
No params is not a mandatory argument to takqueue.add() I guess.
Because it does not throw any syntax error if not provided.

On Feb 10, 8:52 pm, howesc how...@umich.edu wrote:
 some questions/thoughts:

  - local test server or production?
  - did you check the task queue?  in production go to the admin console and
 find the task queues link.  in local test go to /_ah/admin and find the
 task queue link
  - is params a required argument to taskqueue.add()?  i don't know if i
 always use it cause i need it or cause it is required.




[web2py] Re: Problem with update [Closed]

2012-02-13 Thread weheh
.


[web2py] Re: how to pass db object to component?

2012-02-13 Thread Anthony
Is this an ajax component? In that case, all the LOAD helper is doing is 
setting up the JS code to make an ajax GET request to the component's URL, 
so you can't easily pass large amounts of data to the component function. 
If you only need the results of the query within the component, you might 
be better off doing the query in the component function (i.e., f1() in your 
example). Otherwise, maybe cache the results of the query and have the 
component function pull it out of the cache (or put it in the session if 
the results are unique per user).

Anthony

On Monday, February 13, 2012 11:17:50 PM UTC-5, weheh wrote:

 What, if any, is the proper syntax for passing a db storage object to 
 a component? 

 In other words: 

 # controller 
 def index(): 
 query=... 
 return dict(data=db(query).select()) 

 # view 
 ... 
 {{=LOAD('c1','f1')}} 

 So where in the LOAD statement can I pass in data as a db Storage or 
 must it be a dict? 



[web2py] Re: dataTables with serverside json

2012-02-13 Thread Vineet
Yes.

As a side not, DABO is written fully in Python itself.
It is a full fledged framework using wxPython for GUI.
But I am using its database-interaction tier  business-logic tier
(dabo.biz  dabo.db).

http://www.dabodev.com
http://www.dabodev.com/documentation

-- Vineet

On Feb 13, 8:16 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Hi Vineet,

 Thanks for sharing. So, if I understand correctly, you use DABO code as an
 equivalent of the php code in the example from the DTs to allow grid to
 interact with database...

 I will have a look at PowerTable this week to see if it actually implement
 server processing and if not to try to figure out how we could add the
 feature...

 :)

 Richard







 On Sat, Feb 11, 2012 at 1:08 AM, Vineet vineet.deod...@gmail.com wrote:
  Richard,
  Here is my minimal code for returning json data in dataTables via
  web2py's ajax function.

  ---View---
  !-- here's a well-formed table --
  table id=abc_table
  thead
   tr
     thABC Category Name/th
     thCode/th
   /tr
  /thead
  tbody
  /tbody
  /table

  script
  // this I keep in js folder

  function dtbl_show(hash_div, sAjaxSource, aoColumns) {

         $(document).ready(function() {

     $(hash_div).dataTable( {

         bJQueryUI: true,

         bDeferRender: true,

         bPaginate: true,

         'sPaginationType': 'full_numbers',

         bProcessing: true,

         bServerSide: true,

         aaSorting: [[ 1, desc ]],

         bAutoWidth: false,

         aoColumns : aoColumns,

         sAjaxSource: sAjaxSource

     } );

   } );

                 jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages =
  10;

               }
  /script

  script
  // call here this script  pass the table's div for rendering it

  dtbl_show(#abc_table, {{=URL('abc','get_abcdata')}}, [{ sWidth:
  '350px' }, { sWidth: '200px' }] )
  /script

  --- End View ---

  --- Controller for populating data via ajax ---
  (excuse the bugged-up indentation here)

  def get_abcdata():
   if request_vars_iDisplayStart != None:

         iDisplayStart = request_vars_iDisplayStart

   else:

         iDisplayStart = 0

   if request_vars_iDisplayLength != None:

         iDisplayLength = request_vars_iDisplayLength

   else:

         iDisplayLength = 10

   if request_vars_sEcho != None:

        sEcho = int(request_vars_sEcho)

   else:

        sEcho = 1

   qry = 'your sql query string'

  ### Below this, I am using a 3rd party library viz. DABO for
  interacting with DB.
  ### You may substitute that syntax with the DB layer of your choice
  (DAL or whatever else) and get dataset.

     try:

         conn_name = connInstance.makeConn()

         cur = conn_name.cursor()

         qry = qry1 + ' limit ' + str(iDisplayStart) + ', ' +
  str(iDisplayLength) + ';'

  # fetch total data

         cur.execute(qry1)

         data_full = cur.getDataSet()

         iTotalRecords = len(data_full)

  # fetch data as requested from client

         cur.execute(qry)

         data_disp = cur.getDataSet()

         iTotalDisplayRecords = len(data_full)

     finally:

         conn_name.close()

     aaData = []
  # Now populate the aaData with data in form of lists.
  # e.g. aaDada will look like -- [[1, 'Vineet'],[2,'Richard']]
  # This formatting is important

    D=dict(sEcho=sEcho, iTotalRecords=iTotalRecords,
  iTotalDisplayRecords=iTotalDisplayRecords,
  iDisplayLength=iDisplayLength, aaData=aaData)
    return response.json(D)

  -- End of Controller code --

  That's wraps it up.
  If you need any further drilling down in my code, pl. ask.
  I will be happy to share.

  HTH,
  --- Vineet

  On Feb 8, 10:18 pm, Richard Vézina ml.richard.vez...@gmail.com
  wrote:
   Yes!

   I think the PowerTable of Burno don't implement server side processing
   yet... We maybe can start form there to make a server side implementation
   of PowerTable... What do you think?

   I think, we have to split table header from data then wrote a python
   implementation fo the php script as shown in the example of DTs...

   For sure see a bit of your code could help me figure out the path I
  should
   follow and help my reflexion.

   About fnInitComplete it is just needed in case you want to initialise
  DTs
   with fixed columns...

   Richard

   On Wed, Feb 8, 2012 at 11:52 AM, Vineet vineet.deod...@gmail.com
  wrote:
Hi Richard !
Pl. excuse my late replying.
Glad to hear that you got it working.

If you are interested, I can share my code.
I am not using fnInitComplete.
Mine is very simple  minimal code.

--- Vineet

On Feb 7, 10:19 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Finally got it to work...

 There was a problem with the init of DTs particularly this option :

 http://datatables.net/release-datatables/extras/FixedColumns/server-s...

 *fnInitComplete*
 *
 *
 *
 *
 It's not solving my speed problem as I expect it could do... So I
  will
put
   

[web2py] Re: Conditional deletes (ondelete etc) in sqlform.grid

2012-02-13 Thread Mark Kirkwood

I've worked around this by tackling the issue a different way:

- disable the delete button on the grid altogether with deletable=False
- selectively enable it in edit mode for records that are 
safe/appropriate to delete


Maybe I should have done it this way to begin with - as it is nicer if 
the user only sees actions that are going to work.


On 14/02/12 13:11, Mark Kirkwood wrote:
I am attempting to implement a check that allows deletes only under 
some circumstances. I figured I would do this via the ondelete arg in 
the grid. Unfortunately I have run into a few stumbling blocks with this:


1/ The 1.99.4 code is busted - references 'ret' before it is defined

Fortunately a simple fix (I think you guys have done something like 
this in trunk) -


sqlhtml.py:1294
if ondelete:
#ondelete(table,request.args[-1],ret)
ondelete(table,request.args[-1])

2/ The ondelete function is only called from the main grid delete 
action, not the delete checkbox in edit mode


I would be great if the logic could be applied there too - otherwise I 
guess I can workaround by switching the delete option off in the edit 
screen.



3/ Am unclear about how to signal back that I want delete to stop

I figure I am just being dense in this case, but ondelete function 
accepts table and row id variables (not a form) so I don't see any way 
to set the form's error status.


Thanks for your help

Mark




[web2py] Join operations on google app engine

2012-02-13 Thread Saurabh S
I have an online application deployed on google cloud.

I have used web2py framework to develop the application.

I have 2 tables the auth_user table and tasks table.Both of them have
more than 1000 records each.The tasks table contains person_id field
which stores the id's in auth_user table

I need to fetch the data from 2 tables and display it.

Since I am having large data it results in request time out(Deadline
Exceeded Error).

When I fetch from a single table it works fine. Since Google App
Engine does not support JOIN operations I was fetching the entire
data from both tables and then peforming operations, it would result
to request time out.

So I thought of adding the necessary fields that are in auth_user to
tasks table but since there are more than 1000 records updating each
record manually is cumbersome.

Does web2py provide any bultin methods(like database validations) to
update the fields based on person_id present or I should update it
manually?



[web2py] Re: Routes.py and janrain login

2012-02-13 Thread lyn2py
Or you can click on reload routes in the web2py admin :)

On Feb 14, 12:38 am, Rene Dohmen acidj...@gmail.com wrote:
 Got it working with the example from the web2py book:

 routers = dict(
   BASE  = dict(default_application='formatics'),
 )

 Thank you web2py book :)

 Maybe a nice reminder for people running with mod_wsgi: you have to
 restart the webserver to activate changes in routes.py, and that's why
 it didn't work the 1st time

 R

 On Feb 2, 2:51 am, Rene Dohmen acidj...@gmail.com wrote:







  Hi List,

  I've installed mod_wsgi on our server and added a vhost so that each
  application is accessible viawww.examples.com/app_name

  One of the apps is ready; so I created another vhost and started an
  separate instance of web2py.
  The second instance uses a routes.py to remove the appname from the
  URL.

  You can see it here:http://www.formaticz.nl

  Everything works OK, but when I try to login via the janrain login, I
  get redirected 
  to:http://www.formaticz.nl/formatics/default/user/logininsteadofhttp://www.formaticz.nl/default/user/login
  (making it impossible to login)

  This is the routes.py I used (in root web2py folder).

  routes_in=[['/$anything','/formatics/$anything']]
  routes_out=[['/formatics/$anything','/$anything']]

  I tried adding some extra values to it, but couldn't get it working.

  Kind Regards,Rene


[web2py] Re: dataTables with serverside json

2012-02-13 Thread Vineet
Yes.

As a side not, DABO is written fully in Python itself.
It is a full fledged framework using wxPython for GUI.
But I am using its database-interaction tier  business-logic tier
(dabo.biz  dabo.db).

Since we, web2py followers, are using web2py as a footing, you may
ignore the code regarding ui in the below-referred links.

http://thewinecellarbook.com/daboDocTestAlt/dabo.biz_module.html#dabo-biz
http://thewinecellarbook.com/daboDocTestAlt/dabo.db_module.html#dabo-db
http://thewinecellarbook.com/daboDocTestAlt/
http://www.dabodev.com


-- Vineet

On Feb 13, 8:16 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Hi Vineet,

 Thanks for sharing. So, if I understand correctly, you use DABO code as an
 equivalent of the php code in the example from the DTs to allow grid to
 interact with database...

 I will have a look at PowerTable this week to see if it actually implement
 server processing and if not to try to figure out how we could add the
 feature...

 :)

 Richard







 On Sat, Feb 11, 2012 at 1:08 AM, Vineet vineet.deod...@gmail.com wrote:
  Richard,
  Here is my minimal code for returning json data in dataTables via
  web2py's ajax function.

  ---View---
  !-- here's a well-formed table --
  table id=abc_table
  thead
   tr
     thABC Category Name/th
     thCode/th
   /tr
  /thead
  tbody
  /tbody
  /table

  script
  // this I keep in js folder

  function dtbl_show(hash_div, sAjaxSource, aoColumns) {

         $(document).ready(function() {

     $(hash_div).dataTable( {

         bJQueryUI: true,

         bDeferRender: true,

         bPaginate: true,

         'sPaginationType': 'full_numbers',

         bProcessing: true,

         bServerSide: true,

         aaSorting: [[ 1, desc ]],

         bAutoWidth: false,

         aoColumns : aoColumns,

         sAjaxSource: sAjaxSource

     } );

   } );

                 jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages =
  10;

               }
  /script

  script
  // call here this script  pass the table's div for rendering it

  dtbl_show(#abc_table, {{=URL('abc','get_abcdata')}}, [{ sWidth:
  '350px' }, { sWidth: '200px' }] )
  /script

  --- End View ---

  --- Controller for populating data via ajax ---
  (excuse the bugged-up indentation here)

  def get_abcdata():
   if request_vars_iDisplayStart != None:

         iDisplayStart = request_vars_iDisplayStart

   else:

         iDisplayStart = 0

   if request_vars_iDisplayLength != None:

         iDisplayLength = request_vars_iDisplayLength

   else:

         iDisplayLength = 10

   if request_vars_sEcho != None:

        sEcho = int(request_vars_sEcho)

   else:

        sEcho = 1

   qry = 'your sql query string'

  ### Below this, I am using a 3rd party library viz. DABO for
  interacting with DB.
  ### You may substitute that syntax with the DB layer of your choice
  (DAL or whatever else) and get dataset.

     try:

         conn_name = connInstance.makeConn()

         cur = conn_name.cursor()

         qry = qry1 + ' limit ' + str(iDisplayStart) + ', ' +
  str(iDisplayLength) + ';'

  # fetch total data

         cur.execute(qry1)

         data_full = cur.getDataSet()

         iTotalRecords = len(data_full)

  # fetch data as requested from client

         cur.execute(qry)

         data_disp = cur.getDataSet()

         iTotalDisplayRecords = len(data_full)

     finally:

         conn_name.close()

     aaData = []
  # Now populate the aaData with data in form of lists.
  # e.g. aaDada will look like -- [[1, 'Vineet'],[2,'Richard']]
  # This formatting is important

    D=dict(sEcho=sEcho, iTotalRecords=iTotalRecords,
  iTotalDisplayRecords=iTotalDisplayRecords,
  iDisplayLength=iDisplayLength, aaData=aaData)
    return response.json(D)

  -- End of Controller code --

  That's wraps it up.
  If you need any further drilling down in my code, pl. ask.
  I will be happy to share.

  HTH,
  --- Vineet

  On Feb 8, 10:18 pm, Richard Vézina ml.richard.vez...@gmail.com
  wrote:
   Yes!

   I think the PowerTable of Burno don't implement server side processing
   yet... We maybe can start form there to make a server side implementation
   of PowerTable... What do you think?

   I think, we have to split table header from data then wrote a python
   implementation fo the php script as shown in the example of DTs...

   For sure see a bit of your code could help me figure out the path I
  should
   follow and help my reflexion.

   About fnInitComplete it is just needed in case you want to initialise
  DTs
   with fixed columns...

   Richard

   On Wed, Feb 8, 2012 at 11:52 AM, Vineet vineet.deod...@gmail.com
  wrote:
Hi Richard !
Pl. excuse my late replying.
Glad to hear that you got it working.

If you are interested, I can share my code.
I am not using fnInitComplete.
Mine is very simple  minimal code.

--- Vineet

On Feb 7, 10:19 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Finally got it to work...

 

[web2py] Re: dataTables with serverside json

2012-02-13 Thread Vineet
Yes.

As a side note, DABO is written fully in Python itself.
It is a full fledged framework using wxPython for GUI.
But I am using its database-interaction tier  business-logic tier
(dabo.biz  dabo.db).

Since we, web2py followers, are using web2py as a footing, you may
ignore the code regarding ui in the below-referred links.

http://thewinecellarbook.com/daboDocTestAlt/dabo.biz_module.html#dabo...
http://thewinecellarbook.com/daboDocTestAlt/dabo.db_module.html#dabo-db
http://thewinecellarbook.com/daboDocTestAlt/
http://www.dabodev.com

-- Vineet

On Feb 13, 8:16 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Hi Vineet,

 Thanks for sharing. So, if I understand correctly, you use DABO code as an
 equivalent of the php code in the example from the DTs to allow grid to
 interact with database...

 I will have a look at PowerTable this week to see if it actually implement
 server processing and if not to try to figure out how we could add the
 feature...

 :)

 Richard







 On Sat, Feb 11, 2012 at 1:08 AM, Vineet vineet.deod...@gmail.com wrote:
  Richard,
  Here is my minimal code for returning json data in dataTables via
  web2py's ajax function.

  ---View---
  !-- here's a well-formed table --
  table id=abc_table
  thead
   tr
     thABC Category Name/th
     thCode/th
   /tr
  /thead
  tbody
  /tbody
  /table

  script
  // this I keep in js folder

  function dtbl_show(hash_div, sAjaxSource, aoColumns) {

         $(document).ready(function() {

     $(hash_div).dataTable( {

         bJQueryUI: true,

         bDeferRender: true,

         bPaginate: true,

         'sPaginationType': 'full_numbers',

         bProcessing: true,

         bServerSide: true,

         aaSorting: [[ 1, desc ]],

         bAutoWidth: false,

         aoColumns : aoColumns,

         sAjaxSource: sAjaxSource

     } );

   } );

                 jQuery.fn.dataTableExt.oPagination.iFullNumbersShowPages =
  10;

               }
  /script

  script
  // call here this script  pass the table's div for rendering it

  dtbl_show(#abc_table, {{=URL('abc','get_abcdata')}}, [{ sWidth:
  '350px' }, { sWidth: '200px' }] )
  /script

  --- End View ---

  --- Controller for populating data via ajax ---
  (excuse the bugged-up indentation here)

  def get_abcdata():
   if request_vars_iDisplayStart != None:

         iDisplayStart = request_vars_iDisplayStart

   else:

         iDisplayStart = 0

   if request_vars_iDisplayLength != None:

         iDisplayLength = request_vars_iDisplayLength

   else:

         iDisplayLength = 10

   if request_vars_sEcho != None:

        sEcho = int(request_vars_sEcho)

   else:

        sEcho = 1

   qry = 'your sql query string'

  ### Below this, I am using a 3rd party library viz. DABO for
  interacting with DB.
  ### You may substitute that syntax with the DB layer of your choice
  (DAL or whatever else) and get dataset.

     try:

         conn_name = connInstance.makeConn()

         cur = conn_name.cursor()

         qry = qry1 + ' limit ' + str(iDisplayStart) + ', ' +
  str(iDisplayLength) + ';'

  # fetch total data

         cur.execute(qry1)

         data_full = cur.getDataSet()

         iTotalRecords = len(data_full)

  # fetch data as requested from client

         cur.execute(qry)

         data_disp = cur.getDataSet()

         iTotalDisplayRecords = len(data_full)

     finally:

         conn_name.close()

     aaData = []
  # Now populate the aaData with data in form of lists.
  # e.g. aaDada will look like -- [[1, 'Vineet'],[2,'Richard']]
  # This formatting is important

    D=dict(sEcho=sEcho, iTotalRecords=iTotalRecords,
  iTotalDisplayRecords=iTotalDisplayRecords,
  iDisplayLength=iDisplayLength, aaData=aaData)
    return response.json(D)

  -- End of Controller code --

  That's wraps it up.
  If you need any further drilling down in my code, pl. ask.
  I will be happy to share.

  HTH,
  --- Vineet

  On Feb 8, 10:18 pm, Richard Vézina ml.richard.vez...@gmail.com
  wrote:
   Yes!

   I think the PowerTable of Burno don't implement server side processing
   yet... We maybe can start form there to make a server side implementation
   of PowerTable... What do you think?

   I think, we have to split table header from data then wrote a python
   implementation fo the php script as shown in the example of DTs...

   For sure see a bit of your code could help me figure out the path I
  should
   follow and help my reflexion.

   About fnInitComplete it is just needed in case you want to initialise
  DTs
   with fixed columns...

   Richard

   On Wed, Feb 8, 2012 at 11:52 AM, Vineet vineet.deod...@gmail.com
  wrote:
Hi Richard !
Pl. excuse my late replying.
Glad to hear that you got it working.

If you are interested, I can share my code.
I am not using fnInitComplete.
Mine is very simple  minimal code.

--- Vineet

On Feb 7, 10:19 pm, Richard Vézina ml.richard.vez...@gmail.com
wrote:
 Finally got it to work...

 

[web2py] Re: How to Change the date format

2012-02-13 Thread Rahul
Hi ,

import datetime
now = datetime.datetime.now()

#You probably need something like below --
date = now.strftime(%d %b %Y)

Some more cool and excellent Date manipulation and display tactics
at:
http://www.saltycrane.com/blog/2008/06/how-to-get-current-date-and-time-in/


Regards, Rahul D (www.flockbird.com)


On Feb 13, 12:49 pm, Manuele Pesenti manuele.pese...@gmail.com
wrote:
 Il 13/02/2012 08:40, Sanjeet Kumar ha scritto: Hi to all,

  I want to change the date format during the insertion in database
  default is YYY-MM-DD but i want to insert in database by using the DD-
  MM- and Month should be in the 'jan' format .

  Please help me

 have a look here

 http://web2py.com/books/default/chapter/29/7

 and here

 http://docs.python.org/library/datetime.html#strftime-and-strptime-be...

 :)

      M.


[web2py] * DATE FIELDS REPRESENT *

2012-02-13 Thread cyber
Hi there!
Please help me deal with date representation.

For example, I have a date field:
 Field('date_start', 'date', default = datetime.date.today())
 db.contracts.date_start.represent = lambda v:v.strftime('%d.%m.
%Y')

It works perfectly if I use SQLFORM.
But if I use just selection from db and do something like this in a
view:
 {{for row in contracts:}}
  td{{=row.date_start}}/td
 {{pass}}
it turns to the defaul value representation: %Y-%m-%d.
So in this case I should use strftime for correct all date values:
{{=row.date_start.strftime(%d.%m.%Y)}}
But maybe there is a better way to go!?!

And another question about datetime picker in forms.
By default input value looks like that 2012-02-14.
I need to change it to 14.02.2012.
How can I change it? Where should I look for?


I'll appreciate for any help. Thanks!


[web2py] Re: Multiple different problems - Dealing with Integrity Error for nutnull=True and unique=True database fields

2012-02-13 Thread Rahul
All,
Pondering over with Anthony's solution, I just uploaded images to
static folder and that works wonders for image caching.
Below is the code that I changed in db.py for my model -

Field('profile_pic', 'upload', uploadfolder=request.folder
+'static/user_pics',  requires=IS_LENGTH(262144)),

Just a minor hiccup that it sometimes or initially loads the images
partially (esp png files, not tried with gif's) . Still, I am happy
with the way images are being rendered now. I will still consider the
below solution from Anthony for more further analysis..

Thanks for getting back so quickly .. .web2py community is superb!

Regards, Rahul D (www.flcokbird.com)


On Feb 13, 9:55 pm, Anthony abasta...@gmail.com wrote:
 On Monday, February 13, 2012 5:40:53 AM UTC-5, Rahul wrote:

  Hi All,
         I am using the below statement to serialize images in my view
  -
  {{=TAG.img(_width=25, _height=30, _src=URL(r=request, c='default',
  f='download', args=[adminupdate.profile_pic]))}}

 Maybe something like:

 {{=TAG.img(_width=25, _height=30, _src=URL(r=request, c='default',
 f='download', args=[adminupdate.profile_pic], vars=dict(cache=True)))}}

 def download():
     if 'cache' in request.vars:
         response.headers['Cache-Control'] = 'max-age=3600'
     response.download(request, db)

 Anthony


[web2py] request.args returns each arg as string

2012-02-13 Thread Annet
I posted a question asking why this doesn't work:

if request.args(0)==1

the answer: request.args returns each arg as string

However, in my application I use this multiple times:

rows=db(db.node.id==request.args(0)).select(db.node.ALL)

where id is of type integer and not string. What is the difference
between the first use request.args(0) and the second use?


Kind regards,

Annet.


[web2py] request.args returns each arg as string

2012-02-13 Thread Annet
I posted a question asking why this doesn't work:

if request.args(0)==1

the answer: request.args returns each arg as string

However, in my application I use this multiple times:

rows=db(db.node.id==request.args(0)).select(db.node.ALL)

where id is of type integer and not string. What is the difference
between the first use request.args(0) and the second use?


Kind regards,

Annet.


Re: [web2py] request.args returns each arg as string

2012-02-13 Thread Bruno Rocha
in the second example the DAL query operator == is taking care of trying to
convert your data to the right type.

http://zerp.ly/rochacbruno
Em 14/02/2012 05:14, Annet anneve...@googlemail.com escreveu:

 I posted a question asking why this doesn't work:

 if request.args(0)==1

 the answer: request.args returns each arg as string

 However, in my application I use this multiple times:

 rows=db(db.node.id==request.args(0)).select(db.node.ALL)

 where id is of type integer and not string. What is the difference
 between the first use request.args(0) and the second use?


 Kind regards,

 Annet.


Re: [web2py] CSV Import performance improvement idea

2012-02-13 Thread Johann Spies
On 14 February 2012 00:54, Omi Chiba ochib...@gmail.com wrote:

 I have a problem with the performance of CSV import and I assume it
 generate INSERT statement for every record so it will be 8000
 statement if you have 8000 records in csv file.

 Can we use bulk_insert method instead so there will be always only one
 INSERT statement  which should reduce the performance significantly ?

 As I understand it the database (at least Postgresql) uses the COPY
statement to import csv-files.  That is much quicker than a series of
individual inserts.

Regards
Johann


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