[web2py] Update record in session
Is is possible to hold a record in session, something like: id = db.transactions.insert() session.transaction = db.transactions[id] and directly update_record the session.transaction, session.transaction.update_record(x=y)# This throws KeyError: 'update_record' or is it necessary to reselect the record each time the controller is called? if session.transaction: transaction=db.transaction[session.transaction.id] transaction.update_record(x=y)
[web2py] Re: custom.widget manipulation with checkboxes
Got the solution myself. The right code is: form.custom.widget['myfield']['_checked'] = db((db.mytable.id==id).select(db.mytable.myfield).first() #updated form.custom.widget['myfield']._postprocessing() On 6 Feb., 17:55, Serbitar wrote: > I can do something like this: > > fields = [Field('myfield', type = integer, default = > db((db.mytable.id==id).select(db.mytable.myfield).first()] > form=SQLFORM.factory( *fields) > > if form.accepts(request.vars, session): > db(db.mytable.id==id).update(myfield=form.vars[entry]) > > form.custom.widget['myfield']['value'] = > db((db.mytable.id==id).select(db.mytable.myfield).first() #updated > value > form.custom.widget['myfield']._postprocessing() > > intention: > I can make a custom form that updates several databases/field > combinations, but I want to instantly show these changes in the form > and thus have to update the form values. Otherwise I will continually > alternate the changes between database and form. > > this works as intended. > > BUT: > > If I want to do the same thing with "boolean" datatypes (and > checkboxes in the form) this does not work. > > I tried: > > form.custom.widget['myfield']['value'] = > db((db.mytable.id==id).select(db.mytable.myfield).first() #updated > value > form.custom.widget['myfield']._postprocessing() > > form.custom.widget['myfield']['value'] = True > form.custom.widget['myfield']._postprocessing() > > form.custom.widget['myfield']['checkbox'] = "checked" > form.custom.widget['myfield']._postprocessing() > > and such, but It never shows and I get the "alternating" behaviour > (either form or database is updated but never both at the same time). > > Question: How do I change theform.custom.widgetvalues of checkbox > widgets ?
[web2py] Re: Update record in session
session is not the database. you can save the transactionid into the session and update the db in the controller. e.g. id = db.transactions.insert() session.transaction = id db(db.transactions.id == session.transaction).update(x=y) or you can manage transaction record in the session and update the db at the last step e.g. from gluon.storage import Storage id = db.transaction.insert() session.transaction = Storage() session.transaction.id = id session.transaction.otherfield = x . session.transaction.otherfield = y db(db.transaction.id == session.transaction.id).update(otherfield = session.transaction.otherfield) In any case, if you save something to session and you want that change saved into the database, you have to do a specific update using db(...).update()
[web2py] Re: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
logging in /var/log/uwsgi-python is pertinent to uwsgi-python. you probably have the directive --memory-report in your app configuration. ( in xml, etc.)
[web2py] Re: Advice please: best way to count records?
The two methods you described are the only available methods to achieve such a thing. If you have 100 records returned and you want to paginate by 20 (5 pages), then the difference between one method or the other is negligible. If you have 1000 records returned and you want to paginate by 20 (50 pages), then the best method is fire a "count" and a separated limitby for retrieving the records. Remember you can fire a db(query).count() and cache that: the record count will be fetched one time only and from then on from the cache and the db will be hitted only by the limitby query. e.g. total = db(db.pages.active==True).count(cache=(cache.ram,120)) records = db(db.pages.active==True).select(limitby=(0,20))
[web2py] Re: Update legacy table using primarykey failed
can you post the html generated by the form before submitting the record and the "beautified" session ? In order to avoid race conditions, web2py places some hidden fields in the form and store a key in the session when accessing a edit form: seems that this fields don't match, hence the traceback.
[web2py] query on a JOIN
Hello everyone! In the example in the book for JOIN, http://web2py.com/books/default/chapter/29/6#Inner-joins how can you write a query that only returns the dogs that Alex has? I need to have access to all the fields for Alex and all the fields for the dogs he has (This is not my exact problem but mine is similar) Any help would be appreciated! =)
[web2py] Modules: how to access db
I am not ready with this project to try out Bruno's way of setting up a database using modules and not models. But I want to be able to do something like this in a module: def number_or_records(table): count = db(db[table]).count() -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Modules: how to access db
Sorry the message was sent before I have finished typing. How do I get the same environment available in the module as in the controller? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Modules: how to access db
from gluon import * This should give you the "current" object which has these: current.request current.response current.cache You must initialize your modules with a db instance though. So I usually do this: class MyModule(object): def __init__(self, db, ...)
Re: [web2py] Re: keep shared objects permanently in RAM: Is it possible ?
Thanks for pointing that out Michele. I may need to use something like this in the future.
[web2py] Re: option to move smartgrid buttons to the left side
I was wondering about the previously. I haven't tried this yet, but as a temporary workaround, are you able to insert buttons using JavaScript?
Re: [web2py] query on a JOIN
Il 09/02/2012 12:33, shartha ha scritto: how can you write a query that only returns the dogs that Alex has? you can add your filter condition to the join condition usch as: rows = db((db.person.id==db.dog.owner)&(db.person.id==1)).select() If I understand the quest... M.
[web2py] Re: xml-rpc code causes compile error in mywiki default.py
You have a syntax error in fony_by(keyword): return db(db.page.title.contains(keyword).select().as_list() Should be: return db(db.page.title.contains(keyword)).select().as_list() You forgot the closing parenthesis before .select().
[web2py] Re: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
Hi Niphlod, No, I do not have that option / directive on. What other directive could be the problem?. Btw I do have: Thanks again, Carlos
[web2py] Multiple different problems - Dealing with "Integrity Error" for nutnull=True and unique=True database fields
Hi All, I have three problems - Please help me understand how to troubleshoot these Problem1 - (Primary issue) I have a table as below - How do I handle unique = True and notnull= True fields i.e when I am doing negative testing and adding similar fields, it throws me an exception. I am using web2py 1.99.4 , win7 and sqlite3 #users will be registered using email and password db.define_table('reguser', Field('first_name', length=128), Field('last_name', length=128), Field('date_of_birth','date', requires=IS_DATE(format='%m/%d/%Y')), Field('marital_status', length=10, requires=IS_IN_SET(marital_status)), Field('gender', requires=IS_IN_SET(["Male", "Female", "Other"])), Field('cell_no', length=15), Field('email', length=512, unique=True, notnull=True), Field('address', length=512), Field('city', length=256), Field('zip', length=10), Field('unique_code', length=128, unique=True ), #, comment='Eg. Architects code' Field('profile_pic', 'upload'), Field('created_on', 'date' , default= now, writable=False), Field('user_type', requires=IS_IN_SET(user_types)), Field('user_status', requires=IS_IN_SET(user_status)), Field('user_rights', requires=IS_IN_SET(user_rights)), Field('user_name', length=128, label='Display Name'), Field('password', 'password'), Field('password_question', length=128), Field('answer', length=128) ) Error Message- Traceback (most recent call last): File "D:\WEB2PY\web2py\gluon\restricted.py", line 204, in restrictedexec ccode in environment File "D:\WEB2PY\web2py\applications\Build_Connect\controllers/ default.py", line 998, in File "D:\WEB2PY\web2py\gluon\globals.py", line 172, in self._caller = lambda f: f() File "D:\WEB2PY\web2py\applications\Build_Connect\controllers/ default.py", line 86, in sysloginform = crud.create(db.reguser) File "D:\WEB2PY\web2py\gluon\tools.py", line 3126, in create formname=formname, File "D:\WEB2PY\web2py\gluon\tools.py", line 3069, in update detect_record_change = self.settings.detect_record_change): File "D:\WEB2PY\web2py\gluon\sqlhtml.py", line 1267, in accepts self.vars.id = self.table.insert(**fields) File "D:\WEB2PY\web2py\gluon\dal.py", line 5597, in insertreturn self._db._adapter.insert(self,self._listify(fields)) File "D:\WEB2PY\web2py\gluon\dal.py", line 914, in insertraise eIntegrityError: column email is not unique --- Problem2: How can I cache images that I have added for users who have added comments. Example- I have a web page where I have users comment over my posts. These users have id's defined and photos specified, how can I prevent loading one image at a time? Problem3: How to restrict upload of files (any files including images) to say 512 kb or any size there of? Regards, Rahul (www.flockbird.com)
[web2py] Folder inside controller dosen't work.
Is that a bug or by design? I am using JSONRPC of web2py , i want to keep JSONRPC services int its own subfolder so not mixed with controllers for html. But web2py is not allowing me to do so. Here is my web2py's conttrolelr path: /home/v3ss/web2py/applications/FastTract/controllers/ i want to put caselist.py (which is to deal with case table part of the project) inside services folder. so it should look like this : /home/v3ss/web2py/applications/FastTract/controllers/services/case.py All jsonRPC related services will go inside that folder. But when i tried to call : http://localhost:8000/FastTract/services/case/call/jsonrpc?nocache=1328793441550 invalid controller (services/case) What can i do? I believe code folder organisation is very important feature for Large complex systems. My Project is growing big and should be able to organize code. 50 files of code spreading inside just one controller folder is a management nightmare. Thanks.
Re: [web2py] Re: Modules: how to access db
Thanks Ross. On 9 February 2012 14:39, Ross Peoples wrote: > from gluon import * > > This should give you the "current" object which has these: > > current.request > current.response > current.cache > > You must initialize your modules with a db instance though. So I usually > do this: > > class MyModule(object): > def __init__(self, db, ...) > I do not understand this properly. After explicitly importing 'current' in the controller, I made some progress. But why is the class definition necessary and how does it initialise db when db is not available in the module? Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
Re: [web2py] Re: Modules: how to access db
> > I do not understand this properly. > > After explicitly importing 'current' in the controller, I made some > progress. But why is the class definition necessary and how does it > initialise db when db is not available in the module? > You don't necessarily need a class. The point is just that you need to pass in the db instance, either via an __init__ method of a class, or simply as an argument to your function. In your case: def number_of_records(db, table): And when you call that function, pass in your db object as the first argument. Another option is to add the db object to "current" -- for example, in the db.py model file: from gluon import current current.db = db Then when you import current in your module, you can refer to current.db. Anthony
Re: [web2py] Re: Modules: how to access db
On 9 February 2012 15:45, Anthony wrote: > I do not understand this properly. >> >> After explicitly importing 'current' in the controller, I made some >> progress. But why is the class definition necessary and how does it >> initialise db when db is not available in the module? >> > > You don't necessarily need a class. The point is just that you need to > pass in the db instance, either via an __init__ method of a class, or > simply as an argument to your function. In your case: > > def number_of_records(db, table): > > And when you call that function, pass in your db object as the first > argument. Another option is to add the db object to "current" -- for > example, in the db.py model file: > > from gluon import current > current.db = db > > Then when you import current in your module, you can refer to current.db. > > Thanks Anthony. That clears up a few things for me. Regards Johann -- Because experiencing your loyal love is better than life itself, my lips will praise you. (Psalm 63:3)
[web2py] Re: Folder inside controller dosen't work.
I saw other people requested long ago since 2009. Why it would be a bad addition to web2py , i cant understand. There are many uses cases for it , my case is one very good example : To separate WEB CONTROLLER code from JSON/XML RPC Services. On 2/9/12, Phyo Arkar wrote: > Is that a bug or by design? > > I am using JSONRPC of web2py , i want to keep JSONRPC services int its own > subfolder so not mixed with controllers for html. But web2py is not > allowing me to do so. > > > Here is my web2py's conttrolelr path: > > /home/v3ss/web2py/applications/FastTract/controllers/ > > i want to put caselist.py (which is to deal with case table part of the > project) > inside services folder. so it should look like this : > > /home/v3ss/web2py/applications/FastTract/controllers/services/case.py > > > All jsonRPC related services will go inside that folder. > > But when i tried to call : > http://localhost:8000/FastTract/services/case/call/jsonrpc?nocache=1328793441550 > > invalid controller (services/case) > What can i do? I believe code folder organisation is very important feature > for Large complex systems. My Project is growing big and should be able to > organize code. > 50 files of code spreading inside just one controller folder is a > management nightmare. > > Thanks. >
[web2py] Select Where first letter is A
Dear All , How Can i select everything in the table the starts with A Best Regards, Hassan Alnatour
[web2py] Re: Multiple different problems - Dealing with "Integrity Error" for nutnull=True and unique=True database fields
> > Problem1 - (Primary issue) > I have a table as below - How do I handle unique = True and > notnull= True fields i.e when I am doing negative testing and adding > similar fields, it throws me an exception. If you set unique=True and notnull=True and then try to insert non-unique or null values, respectively, it is supposed to throw an exception. If you want to enter non-unique or null values, then don't set those arguments to true. On the other hand, if you want to catch those errors more gracefully during form submission, then you should use field validators. For unique=True, use the IS_NOT_IN_DB validator, and for notnull=True, use the IS_NOT_EMPTY validator. Note, if you don't specify any "requires" attribute for the field, these validators should be added automatically. However, the validators will only be used for form submissions when using SQLFORM or when using the validate_and_insert() method for making inserts. If you are doing manual inserts via the insert() method, the validators won't have any effect. Another option is to put your insert in a try...except, and catch the IntegrityError. > Problem2: > How can I cache images that I have added for users who have added > comments. > Example- > I have a web page where I have users comment over my posts. These > users have id's defined and photos specified, how can I prevent > loading one image at a time? > If it is OK for the images to be publicly accessible, you could upload them to the /static folder instead of /uploads -- in that case, once initially loaded by the browser, the browser should cache them for subsequent displays. Otherwise, if you are using the download() function to download from the /uploads folder, you could add some logic to the download function to have it set the response headers to tell the browser to cache the images (i.e., same as static files) -- you could use a URL arg or var as a flag to tell the download function to do that. > Problem3: > How to restrict upload of files (any files including images) to say > 512 kb or any size there of? > Use the IS_LENGTH validator: Field('image', 'upload', requires=IS_LENGTH(524288)) The first argument to IS_LENGTH is the maximum file size in bytes (512KB = 524288 bytes). You can also specify a minimum size as the second argument if needed (default is 0). Anthony
[web2py] Re: Advice please: best way to count records?
Would another option be to cache the entire select and pull out the needed records based on the "page" requested: records = db(db.pages.active==True).select(cache=(cache.ram, 300)) I suppose that wouldn't be a good idea if there are likely to be enough records and/or enough simultaneous users with different cached queries to start pushing the limits on available ram, but may be workable for moderate loads. Anthony On Thursday, February 9, 2012 5:17:52 AM UTC-5, Niphlod wrote: > > The two methods you described are the only available methods to achieve > such a thing. > > If you have 100 records returned and you want to paginate by 20 (5 pages), > then the difference between one method or the other is negligible. > > If you have 1000 records returned and you want to paginate by 20 (50 > pages), then the best method is fire a "count" and a separated limitby for > retrieving the records. > > Remember you can fire a db(query).count() and cache that: the record count > will be fetched one time only and from then on from the cache and the db > will be hitted only by the limitby query. > > e.g. > total = db(db.pages.active==True).count(cache=(cache.ram,120)) > records = db(db.pages.active==True).select(limitby=(0,20)) > >
[web2py] best way to fetch data from multiple tables?
I have to query 3 tables which contains large number of data I have to come up with report which displays Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname and Organisation name. Table Structure/Details: 1. Employee table: which contains employee information(First name, lastname), Organisation id and manager's id. 2. Manager Table: Which contains firstname, lastname etc. 3. Organisation table: which contains organisation's name. The process i follow is: 1. Fetch all the employees 1.a for each employee get the manager id 1.b For the manager id get the manager's firstname and lastname by querying the Manager table 1.c for each employee get the organisation id 1.d For each organisation id get the Organisation name by querying the Organisation table. When I try to fetch the records from 3 tables following the above approach, I get deadlineexceedederror as my request could not complete in 30 seconds time. Please suggest a better way to do this. Also what should i use which can improve performance and also get me the result in the 30 second timeframe.
Re: [web2py] Select Where first letter is A
>From manual: http://web2py.com/books/default/chapter/29/6#like,-startswith,-contains,-upper,-lower db.mytable.myfield.startswith('value') On Thu, Feb 9, 2012 at 11:06 AM, Web2Py Freak wrote: > Dear All , > > How Can i select everything in the table the starts with A > > Best Regards, > Hassan Alnatour >
[web2py] Re: best way to fetch data from multiple tables?
Sound like you're looping all the records to connect different table. I use join for the purpose and working fine though I only have about 1 records. http://www.web2py.com/books/default/chapter/29/6?search=join#Inner-joins On Feb 9, 8:19 am, Sonal_b wrote: > I have to query 3 tables which contains large number of data > > I have to come up with report which displays > > Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname > and Organisation name. > > Table Structure/Details: > > 1. Employee table: which contains employee information(First name, > lastname), Organisation id and manager's id. > 2. Manager Table: Which contains firstname, lastname etc. > 3. Organisation table: which contains organisation's name. > > The process i follow is: > 1. Fetch all the employees > 1.a for each employee get the manager id > 1.b For the manager id get the manager's firstname and > lastname by querying the Manager table > 1.c for each employee get the organisation id > 1.d For each organisation id get the Organisation name by > querying the Organisation table. > > When I try to fetch the records from 3 tables following the above > approach, I get deadlineexceedederror as my request could not complete > in 30 seconds time. > > Please suggest a better way to do this. Also what should i use which > can improve performance and also get me the result in the 30 second > timeframe.
Re: [web2py] Re: Modules: how to access db
On Thu, Feb 9, 2012 at 11:45 AM, Anthony wrote: > from gluon import current > current.db = db > I dont think that adding db to current will work properly, it can work in SQLITE, but for sure will raise problems with another databases. I realized that db needs to be instantiated inside a module or passed explicitly as an arg, it is not possible to serialize it in to current. It works in the first request, but not for the subsequents. Another advice is that you never have to assign variables to current outside functions and methods Example. *Module.py* from gluon import current > request = current.request > > def myfunction(db): > if request.args... # HERE BE THE DRAGONS! > To work you need to do *Module.py* from gluon import current def myfunction(db): request = current.request if request.args # IT WORKS It happens because if you assign outside the function, it will be evaluated only at the first request, and for the subsequents, the request object will always be the same. -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: How to replace this native query with DAL
Sorry I just seen this message now, I ended up deleting it by accident and wondering why no-one responded. I will try this today. I didn't know there was a seconds() method attached to the date. Will respond back in a couple of hours when I get to work. -- Thanks, Bruce On Mon, Feb 6, 2012 at 4:51 AM, Niphlod wrote: > hum happen_time is a column of db.cash_journal ? > and you want only the records that satisfy the conditions on the > query, and in addition, that the difference in seconds between > happen_time and now is less than "seconds" (259200) ? > > Without a test db I can't confirm, but can you try something along the > way of (db.cash_journal.happen_time.seconds() < > time.mktime(now.timetuple()) - seconds) > > ? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] Re: Folder inside controller dosen't work.
The main problem is the routing, web2py routes the second arg in url to the function, how would web2py knows if it has to be a function or a subfolder? IMO, controllers have to be small, less code, only code which decide the workflow, the long code I prefer to put in modules, and there I can have subpackages. On Thu, Feb 9, 2012 at 12:05 PM, Phyo Arkar wrote: > I saw other people requested long ago since 2009. > Why it would be a bad addition to web2py , i cant understand. > > There are many uses cases for it , my case is one very good example : > To separate WEB CONTROLLER code from JSON/XML RPC Services. > > > > On 2/9/12, Phyo Arkar wrote: > > Is that a bug or by design? > > > > I am using JSONRPC of web2py , i want to keep JSONRPC services int its > own > > subfolder so not mixed with controllers for html. But web2py is not > > allowing me to do so. > > > > > > Here is my web2py's conttrolelr path: > > > > /home/v3ss/web2py/applications/FastTract/controllers/ > > > > i want to put caselist.py (which is to deal with case table part of the > > project) > > inside services folder. so it should look like this : > > > > /home/v3ss/web2py/applications/FastTract/controllers/services/case.py > > > > > > All jsonRPC related services will go inside that folder. > > > > But when i tried to call : > > > http://localhost:8000/FastTract/services/case/call/jsonrpc?nocache=1328793441550 > > > > invalid controller (services/case) > > What can i do? I believe code folder organisation is very important > feature > > for Large complex systems. My Project is growing big and should be able > to > > organize code. > > 50 files of code spreading inside just one controller folder is a > > management nightmare. > > > > Thanks. > > > -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Folder inside controller dosen't work.
Not sure on the subfolder thing, but is it possible for you to put most of your code into modules and just use controllers as the gateway to your modules?
[web2py] Re: Advice please: best way to count records?
> > I can think of two ways to do it, but I don't like either one. First > is to formulate the query without the limitby clause and do a > db(query).count(). That would give me the total number of records in > the set. Then add the limitby clause to the query to get the records > of interest. FYI, I think this is how SQLFORM.grid does it. Anthony
Re: [web2py] Re: How to replace this native query with DAL
To answer your question, happen_time is a column of cash_journal. The point of this call, is we allow people to cancel the site within 72 hours so any money they have made in that time if they cancel they do not get. IE: payback_types = ['s','p'], s = sponsor bonus, p = product bonus We use seconds to be more accurate so if you join at 5pm we count the 72 hours from 5pm now the full day etc.. On Thu, Feb 9, 2012 at 6:40 AM, Bruce Wade wrote: > Sorry I just seen this message now, I ended up deleting it by accident and > wondering why no-one responded. > > I will try this today. I didn't know there was a seconds() method attached > to the date. Will respond back in a couple of hours when I get to work. > > -- > Thanks, > Bruce > > > On Mon, Feb 6, 2012 at 4:51 AM, Niphlod wrote: > >> hum happen_time is a column of db.cash_journal ? >> and you want only the records that satisfy the conditions on the >> query, and in addition, that the difference in seconds between >> happen_time and now is less than "seconds" (259200) ? >> >> Without a test db I can't confirm, but can you try something along the >> way of (db.cash_journal.happen_time.seconds() < >> time.mktime(now.timetuple()) - seconds) >> >> ? > > > > > -- > -- > 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] Re: best way to fetch data from multiple tables?
Thanks Omi. I will give it a try. Also will it possible for me put filters on table 1(say Employees) and then perform join with other tables? On Feb 9, 7:34 pm, Omi Chiba wrote: > Sound like you're looping all the records to connect different table. > I use join for the purpose and working fine though I only have about > 1 records. > > http://www.web2py.com/books/default/chapter/29/6?search=join#Inner-joins > > On Feb 9, 8:19 am, Sonal_b wrote: > > > > > > > > > I have to query 3tableswhich contains large number ofdata > > > I have to come up with report which displays > > > Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname > > and Organisation name. > > > Table Structure/Details: > > > 1. Employee table: which contains employee information(First name, > > lastname), Organisation id and manager's id. > > 2. Manager Table: Which contains firstname, lastname etc. > > 3. Organisation table: which contains organisation's name. > > > The process i follow is: > > 1.Fetchall the employees > > 1.a for each employee get the manager id > > 1.b For the manager id get the manager's firstname and > > lastname by querying the Manager table > > 1.c for each employee get the organisation id > > 1.d For each organisation id get the Organisation name by > > querying the Organisation table. > > > When I try tofetchthe records from 3tablesfollowing the above > > approach, I get deadlineexceedederror as my request could not complete > > in 30 seconds time. > > > Please suggest a betterwayto do this. Also what should i use which > > can improve performance and also get me the result in the 30 second > > timeframe.
[web2py] response.google_analytics_id
Dear ALL, How do i use response.google_analytics_id in menu.py : my google analytics id is Tracking ID: UA-29069723-1 ,
[web2py] Re: best way to fetch data from multiple tables?
> Also will it possible for me put filters on table 1(say Employees) and> then > perform join with other tables? I'm not sure. I think it's more like join then filter. Something like below... query = (db.person.id==db.dog.owner) & (db.person.name.like('Omi%')) rows = db(query).select() On Feb 9, 8:53 am, Sonal_b wrote: > Thanks Omi. > > I will give it a try. > > Also will it possible for me put filters on table 1(say Employees) and > then perform join with other tables? > > On Feb 9, 7:34 pm, Omi Chiba wrote: > > > > > > > > > Sound like you're looping all the records to connect different table. > > I use join for the purpose and working fine though I only have about > > 1 records. > > >http://www.web2py.com/books/default/chapter/29/6?search=join#Inner-joins > > > On Feb 9, 8:19 am, Sonal_b wrote: > > > > I have to query 3tableswhich contains large number ofdata > > > > I have to come up with report which displays > > > > Employee Firstname, Lastname, Manager's FirstName, Manager's Lastname > > > and Organisation name. > > > > Table Structure/Details: > > > > 1. Employee table: which contains employee information(First name, > > > lastname), Organisation id and manager's id. > > > 2. Manager Table: Which contains firstname, lastname etc. > > > 3. Organisation table: which contains organisation's name. > > > > The process i follow is: > > > 1.Fetchall the employees > > > 1.a for each employee get the manager id > > > 1.b For the manager id get the manager's firstname and > > > lastname by querying the Manager table > > > 1.c for each employee get the organisation id > > > 1.d For each organisation id get the Organisation name by > > > querying the Organisation table. > > > > When I try tofetchthe records from 3tablesfollowing the above > > > approach, I get deadlineexceedederror as my request could not complete > > > in 30 seconds time. > > > > Please suggest a betterwayto do this. Also what should i use which > > > can improve performance and also get me the result in the 30 second > > > timeframe.
[web2py] response.google_analytics_id
Dear All, How can i use response.google_analytics_id in menu.py as i understand i need to have a script with my analytics id , but why is the response.google_analytics_id in menu.py and how can i use it ?
[web2py] Re: Script to generate schema (models) from mysql
Hi I was trying to create model/db.py for RequestTracker mysql schema, and was fail. I found quite good plugin_legacymysql and fixed for my needs - added few types - remove 'SET' lines same as remarks - mysql data types without params (like text,) - import form_factory from sqlhtml Please find fixed py attached. Thanks ''' Create the web2py code needed to access your mysql legacy db. To make this work all the legacy tables you want to access need to have an "id" field. This plugin needs: mysql mysqldump installed and globally available. Under Windows you will probably need to add the mysql executable directory to the PATH variable, you will also need to modify mysql to mysql.exe and mysqldump to mysqldump.exe below. Just guessing here :) Access your tables with: legacy_db(legacy_db.mytable.id>0).select() If the script crashes this is might be due to that fact that the data_type_map dictionary below is incomplete. Please complete it, improve it and continue. Created by Falko Krause ''' from gluon.sqlhtml import form_factory import subprocess import re data_type_map = dict( varchar = 'string', int = 'integer', tinyint = 'integer', smallint = 'integer', mediumint = 'integer', binary = 'text', varbinary = 'text', text = 'text', longtext = 'text', date = 'date', float = 'double', char = 'string', decimal = 'integer', timestamp = 'datetime', datetime = 'datetime', blob = 'text', longblob = 'text', ) def index(): table2sql = '' if not request.vars.database_name: form = form_factory( Field('database_name', requires = IS_NOT_EMPTY()), Field('user_name', requires = IS_NOT_EMPTY()), Field('password', requires = IS_NOT_EMPTY()), ) else: p = subprocess.Popen(['mysql','--user=%s'%request.vars.user_name, '--password=%s'%request.vars.password, '--execute=show tables;', request.vars.database_name],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE) sql_showtables, stderr = p.communicate() form = form_factory( Field('database_name', requires = IS_NOT_EMPTY(), default = request.vars.database_name), Field('user_name', requires = IS_NOT_EMPTY(), default = request.vars.user_name), Field('password', requires = IS_NOT_EMPTY(), default = request.vars.password), Field('write_to', default = 'db_legacymysql.py', requires = IS_NOT_EMPTY()), Field('write', 'boolean', default = False), Field('tables', requires = IS_IN_SET([re.sub('\|\s+([^\|*])\s+.*', '\1', x) for x in sql_showtables.split()[1:]], multiple = True)), ) if form.accepts(request.vars, session, keepvalues = True): # #get a list of tables that should be copied connection_string = "legacy_db = DAL('mysql://%s:%s@localhost/%s')"%(form.vars.user_name, form.vars.password, form.vars.database_name) table2sql = {'connection string': CODE(connection_string)} legacy_db_table_web2py_code = [] for table_name in form.vars.tables: # #get the sql create statement p = subprocess.Popen(['mysqldump','--user=%s'%form.vars.user_name, '--password=%s'%form.vars.password, '--skip-add-drop-table', '--no-data', form.vars.database_name, table_name],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE) sql_create_stmnt,stderr = p.communicate() if stderr: table2sql[table_name] = stderr if 'CREATE' in sql_create_stmnt:#check if the table exists #table2sql[table_name] = stdout if stdout else stderr #DEBUG # #remove garbage lines from sql statement sql_lines = sql_create_stmnt.split('\n') sql_lines = [x for x in sql_lines if not(x.startswith('--') or x.startswith('/*') or x =='' or x.startswith('SET'))] table2sql[table_name] = XML(''.join(sql_lines) ) #DEBUG #generate the web2py code from the create statement web2py_table_code = '' table_name = re.search('CREATE TABLE .(\S+). \(', sql_lines[0]).group(1) fields = [] for line in sql_lines[1:-1]: if re.search('KEY', line) or re.search('PRIMARY', line) or re.search(' ID', line) or line.startswith(')'): continue hit = re.search('(\S+) (\S+) .*', re.sub(',',' ',line)) name, d_type = hit.group(1), hit.group(2)
[web2py] Re: Modules: how to access db
With the last version, you can do this : from gluon import current dba = current.globalenv['db']
[web2py] Re: Update record in session
On Thursday, February 9, 2012 3:10:52 AM UTC-5, scausten wrote: > > Is is possible to hold a record in session, something like: > > id = db.transactions.insert() > session.transaction = db.transactions[id] > > and directly update_record the session.transaction, > > session.transaction.update_record(x=y)# This throws KeyError: > 'update_record' > When a Row is stored in the session, it is converted to a dict and loses its update_record() method (only the field values are stored in the dict). Upon retrieval from the session, it is converted back to a Row object but no longer has the update_record() method, hence the KeyError. Anthony
[web2py] Re: option to move smartgrid buttons to the left side
Thanks Ross. I'm not sure how to do it, plus to assign the same functionality as existing buttons. Do you have some sample from your code? Just tried the application also on the iphone, and (smartgrid) horizontal scroll doesn't work there either... Practically, can't reach buttons :) Anyone else has the similar problem, or advice that could help?
Re: [web2py] Re: Modules: how to access db
Now that is a lot nicer then passing in the db to every module class. Does this only work with trunk? Or the latest stable release? On Thu, Feb 9, 2012 at 7:30 AM, omicron wrote: > With the last version, you can do this : > > from gluon import current > > dba = current.globalenv['db'] > > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: Modules: how to access db
On Thursday, February 9, 2012 10:30:12 AM UTC-5, omicron wrote: > > With the last version, you can do this : > > from gluon import current > > dba = current.globalenv['db'] > I wonder why current.globalenv['db'] would work but current.db would not.
[web2py] Re: Modules: how to access db
based on advice on the group long ago i am using a pattern like this: in db.py: current.myapp = Storage() current.myapp.db = db #after db is inited then in my module refrencing db as: current.myapp.db i'm using this on GAE and it has been working like a champ. the key is to add the just defined version of the db variable to current on each request, and not cache it as a static variable. remember that db changes on each request (new connection from the pool, different default and requests for table fields etc), so you can't keep db a static module variable or a static global variable and have it work for more then 1 request.
[web2py] Re: Modules: how to access db
> > based on advice on the group long ago i am using a pattern like this: > > in db.py: > >current.myapp = Storage() >current.myapp.db = db #after db is inited > If that works, then current.db should work as well, no (I understand the idea behind putting everything app-specific in current.myapp to avoid possible future namespace conflicts, I'm just saying in theory current.db should work, shouldn't it)? Anthony
Re: [web2py] Re: Modules: how to access db
I dont know exactly how it works, but I had problems serializing db in to current, so Massimo said to always pass it explicitly to classes ad functions, I remember that SQLITE worked, but not Postgres. -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: xml-rpc code causes compile error in mywiki default.py
Thanks Ross. Found that this morning. It's a typo in the book. For future readers finding this post on a search; Make sure you put the closing paren in the correct spot or your new error is a bit more substantial. (Python shell returns an error saying, 'Query' object has no attribute 'select' ).
[web2py] Re: how to deploy web2py not in the apache root (help with url rewriting)
If you have just one application all you need to do is set the web2py WSGI script alias and serve files from the web2py folder excluding admin parts. WSGIDaemonProcess web2py display-name=%{GROUP} WSGIProcessGroup web2py WSGIScriptAlias /prefix /var/www/web2py/wsgihandler.py Options +FollowSymLinks AllowOverride None Order Allow,Deny Deny from all Allow from all AliasMatch ^/prefix/([^/]+)/static/(.*) /var/www/web2py/applications/$1/static/$2 Order Allow,Deny Allow from all Deny from all Deny from all Then set path prefix and the default application in your web2py/routes.py file: routers = dict( # base router BASE = dict( default_application = "app", path_prefix = "prefix", ), ) As a result you will get "domain/prefix" pointing to the default application "app".
[web2py] Re: query on a JOIN
Thank you so much. I will try this and let you know how it works. =) On Feb 9, 6:48 am, Manuele Pesenti wrote: > Il 09/02/2012 12:33, shartha ha scritto:> how can you write a query that only > returns the dogs that Alex has? > > you can add your filter condition to the join condition usch as: > > rows = db((db.person.id==db.dog.owner)&(db.person.id==1)).select() > > If I understand the quest... > > M.
[web2py] Re: response.google_analytics_id
if you watch the layout.html you'll find the snippet. {{if response.google_analytics_id:}} var _gaq = _gaq || []; _gaq.push(['_setAccount', '{{=response.google_analytics_id}}']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); {{pass}} just before the closing tag. Short version: if you set response.google_analytics_id, that snippet is inserted into the page and allows tracking from google analytics, without any additional code.
Re: [web2py] Re: Advice please: best way to count records?
Is it just me ? db(query).count(cache=(cache.ram, 60)) Won't work... I get : TypeError: count() got an unexpected keyword argument 'cache' Richard On Thu, Feb 9, 2012 at 9:44 AM, Anthony wrote: > I can think of two ways to do it, but I don't like either one. First >> is to formulate the query without the limitby clause and do a >> db(query).count(). That would give me the total number of records in >> the set. Then add the limitby clause to the query to get the records >> of interest. > > > FYI, I think this is how SQLFORM.grid does it. > > Anthony >
Re: [web2py] Re: Advice please: best way to count records?
Under web2py 1.99.4 Richard On Thu, Feb 9, 2012 at 12:42 PM, Richard Vézina wrote: > Is it just me ? > > db(query).count(cache=(cache.ram, 60)) > > Won't work... > > I get : > > TypeError: count() got an unexpected keyword argument 'cache' > > Richard > > > On Thu, Feb 9, 2012 at 9:44 AM, Anthony wrote: > >> I can think of two ways to do it, but I don't like either one. First >>> is to formulate the query without the limitby clause and do a >>> db(query).count(). That would give me the total number of records in >>> the set. Then add the limitby clause to the query to get the records >>> of interest. >> >> >> FYI, I think this is how SQLFORM.grid does it. >> >> Anthony >> > >
[web2py] Re: Update legacy table using primarykey failed
uhm, this is the relevant part for the form I was asking for for the "session" , just put {{=BEAUTIFY(session)}} into the template and watch the keys Here the strange part is that it seems that employee code is not an integer as defined into the model but a decimal. I don't know if this is the actual problem, but it is different from the "normal" way. Waiting for the session data to see if formkey is different or equal, that is the problem I was addressing in the previous message.
Re: [web2py] Re: Advice please: best way to count records?
I don't think a count can be cached that way, but since it just returns a number, it can be cached in the usual way instead: count = cache.ram('count', lambda: db(query).count(), time_expire=60) Anthony On Thursday, February 9, 2012 12:42:02 PM UTC-5, Richard wrote: > > Is it just me ? > > db(query).count(cache=(cache.ram, 60)) > > Won't work... > > I get : > > TypeError: count() got an unexpected keyword argument 'cache' > > Richard >
[web2py] Re: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
can you post your conf ?If we don't come up with a solution we can rely on roberto de ioris, that is one of uwsgi developers and every now and then joins this list :D
Re: [web2py] Re: Advice please: best way to count records?
I just check gluon/dal.py and if it is the count() code location it's not have cache argument... Also I notice that there seems to have many differents implementations of count... I wouder why it could not be a generic function reused everywhere, it would be more DRY... Richard On Thu, Feb 9, 2012 at 12:48 PM, Anthony wrote: > I don't think a count can be cached that way, but since it just returns a > number, it can be cached in the usual way instead: > > count = cache.ram('count', lambda: db(query).count(), time_expire=60) > > Anthony > > > On Thursday, February 9, 2012 12:42:02 PM UTC-5, Richard wrote: >> >> Is it just me ? >> >> db(query).count(cache=(cache.**ram, 60)) >> >> Won't work... >> >> I get : >> >> TypeError: count() got an unexpected keyword argument 'cache' >> >> Richard >> >
[web2py] Re: option to move smartgrid buttons to the left side
I use sqlform.grid, I use 'links' for edit and delete. These appear as buttons on the right hand column. I have no problem accessing these buttons on my android phone. Are you sure you are attributing the problem correctly? My web2py website is identical on my android phone to what appears on a computer. I have not had to do anything special to achieve this. The website is ukjazz.net. I cannot direct you to the edit buttons unforunately as these are just used by me for admin. If you send me a link to your site I can see what happens on my android phone. Peter On Feb 9, 3:32 pm, Adi wrote: > Thanks Ross. I'm not sure how to do it, plus to assign the same > functionality as existing buttons. Do you have some sample from your code? > > Just tried the application also on the iphone, and (smartgrid) horizontal > scroll doesn't work there either... Practically, can't reach buttons :) > > Anyone else has the similar problem, or advice that could help?
[web2py] Re: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
This is my config for uwsgi-python: 127.0.0.1:9001 /home/www-data/web2py/ 4 wsgihandler Note that I use routes.py, so I'm not sure if these logging lines comes from here (although I have logging = 'off' )?. Thanks!
[web2py] uwsgi configuration: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
ok, this line is dne by uwsgi, and I don't know how to turn it off. Thu Feb 9 17:58:12 2012 - routing 0 routes 0 if you have memory report on, there will be also a line like {address space usage: 46809088 bytes/44MB} {rss usage: 34369536 bytes/32MB} [pid: 17838|app: 0|req: 23/90] 188.10.176.36 () {44 vars in 901 bytes} [Thu Feb 9 17:58:12 2012] GET /app/default/index => generated 12313 bytes in 420 msecs (HTTP/1.1 200) 6 headers in 308 bytes (0 async switches on async core 0) let's wait for someone better than me or roberto himself to know if also the routing 0 routes 0 can be toggled by some directive :D
[web2py] markdown
Markdown display using the imported WIKI function shifts text down by about 1/2em (one half of a line). This is very annoying in a table which no longer lines up vertically. The markdown rendered text column shows up below the other columns across a row. This just looks bad. Is there any reason for the extra vertical padding before the text? It is not part of the markdown "specification" from Gruber. Negative padding on the top doesn't fix this. Even -1px causes most the the rows to display nothing in the column at all, probably because of a slight collision with the bottom of the preceding row. G. All I want is proper line breaks between paragraphs to display and this appeared to be the easiest way to do it without parsing all of the text and inserting tags at every hard return. There is also a minor bug in the __init__ function for markdown where the WIKI function is defined: from markdown2 import * from gluon.html import XML def WIKI(text, encoding="utf8", safe_mode='escape', html4tags=False, **attributes): if not text: test = '' if attributes.has_key('extras'): extras = attributes['extras'] del attributes['extras'] else: extras=None text = text.decode(encoding,'replace') return XML(markdown(text,extras=extras, safe_mode=safe_mode, html4tags=html4tags)\ .encode(encoding,'xmlcharrefreplace'),**attributes) It's pretty clear that it should be if not text: text = ''
[web2py] Re: maybe minor bug or just documentation
Then why did web2py fail with a run time error? Or why wasn't the run time error trapped? Maybe because I had requires on the same table for a different constraint? It doesn't look good when visitors to your site see the web2py error ticket page. Adding the explicit constraint prevented that. Without the explicit constraint, attempting to add a duplicate category produced an error because postgresql threw the error (correctly--it was doing what is was told to do by rejecting a duplicate). Should be easy to repro. Thanks, Anthony. P.S. - I am hanging in there and investing... On Feb 8, 4:51 pm, Anthony wrote: > > In line 14, db.image.title represents the field "title" of table > > "image". The > > attribute requires allows you to set requirements/constraints that > > will be > > enforced by web2py forms. Here we require that the "title" is unique: > > IS_NOT_IN_DB(db, db.image.title) > > Notice this is optional because it is set automatically given that > > Field(’title’, > > unique=True). > > The book says that explicitly adding the IS_NOT_IN_DB validator is optional > because if you specify unique=True but do not explicitly specify any > validators at all, the IS_NOT_IN_DB validator will be assigned > automatically. For example: > > >>> db.define_table('user', Field('username', unique=True)) > >>> print db.user.username.requires > > [, > ] > > Notice that I did not specify the IS_NOT_IN_DB validator in the field > definition, but it was added anyway because I set unique=True. Note, this > only happens if you don't specify "requires" at all. > > Anthony
Re: [web2py] uwsgi configuration: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
> ok, > this line is dne by uwsgi, and I don't know how to turn it off. > Thu Feb 9 17:58:12 2012 - routing 0 routes 0 > > if you have memory report on, there will be also a line like > > {address space usage: 46809088 bytes/44MB} {rss usage: 34369536 > bytes/32MB} > [pid: 17838|app: 0|req: 23/90] 188.10.176.36 () {44 vars in 901 bytes} > [Thu > Feb 9 17:58:12 2012] GET /app/default/index => generated 12313 bytes in > 420 msecs (HTTP/1.1 200) 6 headers in 308 bytes (0 async switches on async > core 0) > > let's wait for someone better than me or roberto himself to know if also > the routing 0 routes 0 can be toggled by some directive :D > Those lines are printed when UWSGI_ROUTING c constant is defined and the only way to do that is passing -DUWSGI_ROUTING to the makefile. The funny thing is that uWSGI routing has been only really added in 1.1 (still unreleased) so i really do not know why you have that flag turned on :) -- Roberto De Ioris http://unbit.it
[web2py] DAL speed - an idea
One of my controllers need to go through a lot of records to provide a meaningful answer -- as in, 60k records. Just loading them from the database takes about 100ms (db.executesql("select * from table order by id;")); Doing the same through DAL takes over 6 seconds. I realize that the DAL does do a lot of additional work, which in general is helpful -- but I can do without all the parsing / Rows() generation for this. What do people here think about adding a db.rawselect(...), which is a slim rapper for db.executesql(db._select()) that wraps everything with a named tuple? It solves most of the speed problem when it is needed, but still maintains a lot of the features of the SQL DAL processing.
Re: [web2py] DAL speed - an idea
You mean using the generated SQL command to fire execute_sql and returns as a named tuple? >>> db(db.query).raw_select() it is the same as doing command = db(db.query)._select() result = db.execute_sql(command) On Thu, Feb 9, 2012 at 4:51 PM, nick name wrote: > One of my controllers need to go through a lot of records to provide a > meaningful answer -- as in, 60k records. > > Just loading them from the database takes about 100ms > (db.executesql("select * from table order by id;")); Doing the same through > DAL takes over 6 seconds. I realize that the DAL does do a lot of > additional work, which in general is helpful -- but I can do without all > the parsing / Rows() generation for this. > > What do people here think about adding a db.rawselect(...), which is a > slim rapper for db.executesql(db._select()) that wraps everything with > a named tuple? It solves most of the speed problem when it is needed, but > still maintains a lot of the features of the SQL DAL processing. > > -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
What I see you are trying to say is that by keeping the code secret one gains a temporary advantage over the competition. That might be true. But this is the way of thinking coming from the proprietary software philosophy. How much will I loose by making the software free? If this is your line of thinking, then maybe writing free software is not what you want to do. Because at the core of the free software movement is a believe, that sharing the code would make the world better. Free software is not here to make us rich. Is not here to make our software easy to (ab)use by business. It is here to preserve out freedoms. It represent an ethical view that sharing knowledge is more important than making money. If you don't agree with that, then the free software is probably not for you. Everyone writing free software should understand that the old business models of proprietary software based on secrecy doesn't apply here. The value is in the collaborative effort to improve the shared code. It shouldn't bother you when somebody else builds on your code and gets ahead of you in terms of features, because this is what you wanted when you decided to write the free software! Instead of complaining that this puts you out of the business you should rather seek for opportunities to collaborate and write more code together which would be good for the business too. And if you want to compete, compete in solving new problems (not the ones that have been already solved, there is no need to duplicate the works of others) and charge your customers for doing that. Now, don't get me wrong. I admit it is not as easy to build a business around the free software as it is in case of proprietary software. But it is not impossible or even especially hard. And is much more fun. This is why we shouldn't give up trying new ways just because they are different to what we know from the proprietary world. On the rise of cloud platforms I see future for the AGPL too.
[web2py] Re: markdown
Here is an easier solution: {{=XML(joke.joke.joketext.replace('\n',''), sanitize=True)}} {{=joke.auth_user.first_name}} {{=joke.auth_user.last_name}} All I really wanted. Didn't need the rest of markdown or markmin. BTW, MARKMIN also pads the top of the text. Curious why this is so but got what I wanted: just use Python. On Feb 9, 10:22 am, Lewis wrote: > Markdown display using the imported WIKI function shifts text down by > about 1/2em (one half of a line). This is very annoying in a table > which no longer lines up vertically. The markdown rendered text > column shows up below the other columns across a row. This just looks > bad. Is there any reason for the extra vertical padding before the > text? It is not part of the markdown "specification" from Gruber. > > Negative padding on the top doesn't fix this. Even -1px causes most > the the rows to display nothing in the column at all, probably because > of a slight collision with the bottom of the preceding row. > > G. All I want is proper line breaks between paragraphs to display > and this appeared to be the easiest way to do it without parsing all > of the text and inserting tags at every hard return. > > There is also a minor bug in the __init__ function for markdown where > the WIKI function is defined: > > from markdown2 import * > from gluon.html import XML > > def WIKI(text, encoding="utf8", safe_mode='escape', html4tags=False, > **attributes): > if not text: > test = '' > if attributes.has_key('extras'): > extras = attributes['extras'] > del attributes['extras'] > else: > extras=None > text = text.decode(encoding,'replace') > > return XML(markdown(text,extras=extras, > safe_mode=safe_mode, html4tags=html4tags)\ > .encode(encoding,'xmlcharrefreplace'),**attributes) > > It's pretty clear that it should be if not text: text = ''
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
I can see your point even though I don't 100% agree with it. I write most of my code opensource, however I also have been writing software for a living for around 14 years so sometimes we don't have the choice between open and closed source. We also can't expect only people interested in free software development to use our software. Considering as you just said the software is there for others to use and if they add more features faster then you and don't give you the features you also can't get upset. Also sharing code and sharing knowledge are not always one and the same. The freedom in software also comes the freedom of choice, to either give back or not, that is why a lot of people prefer the BSD thinking over the GPL thinking. BSD = Doesn't care if someone makes money off their code or not, they just want people using their code. They also have the choice to release their code or not. GPL = Doesn't want anyone making money off their code and forces people to recommit their code. This is good because everyone gets the code, bad because you don't have a choice. I am more of a BSD thinker. On Thu, Feb 9, 2012 at 11:04 AM, Wikus van de Merwe < dupakrop...@googlemail.com> wrote: > What I see you are trying to say is that by keeping the code secret one > gains a temporary advantage over the competition. That might be true. But > this is the way of thinking coming from the proprietary software > philosophy. How much will I loose by making the software free? If this is > your line of thinking, then maybe writing free software is not what you > want to do. > > Because at the core of the free software movement is a believe, that > sharing the code would make the world better. Free software is not here to > make us rich. Is not here to make our software easy to (ab)use by business. > It is here to preserve out freedoms. It represent an ethical view that > sharing knowledge is more important than making money. If you don't agree > with that, then the free software is probably not for you. > > Everyone writing free software should understand that the old business > models of proprietary software based on secrecy doesn't apply here. The > value is in the collaborative effort to improve the shared code. It > shouldn't bother you when somebody else builds on your code and gets ahead > of you in terms of features, because this is what you wanted when you > decided to write the free software! Instead of complaining that this puts > you out of the business you should rather seek for opportunities to > collaborate and write more code together which would be good for the > business too. And if you want to compete, compete in solving new problems > (not the ones that have been already solved, there is no need to duplicate > the works of others) and charge your customers for doing that. > > Now, don't get me wrong. I admit it is not as easy to build a business > around the free software as it is in case of proprietary software. But it > is not impossible or even especially hard. And is much more fun. This is > why we shouldn't give up trying new ways just because they are different to > what we know from the proprietary world. On the rise of cloud platforms I > see future for the AGPL too. > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
Re: [web2py] uwsgi configuration: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
strange, really :D I don't mind if that turns out in the logging, but I have the same behaviour niphlod@platypus:~$ uwsgi-python --version uWSGI 0.9.6.8 I use uwsgi-python in production /usr/bin/uwsgi-python . If I recall correctly that is a symbolic link to `/etc/alternatives/uwsgi-python', and that one is afile symbolic link to `/usr/bin/uwsgi-python2.6' I then have a /usr/bin/uwsgi that is the result of pip-installing uwsgi package: actually I'm experimenting on dropping the uwsgi-python package (some real mess to understand clearly, at least for me, especially with its /etc/init.d scripts) . With the emperor mode it's really easier to manage apps Maybe some "shared libraries" between versions ?
[web2py] Re: Update legacy table using primarykey failed
You're right ! I thought it doesn't matter but it does. I define another table which has a same field type for key and works !! But I employee table doesn't work even I changed from 'string' to 'double' "SyntaxError: user is tampering with form's record_id: {'EmployeeCode': '61339.00'} != {'EmployeeCode': Decimal('61339')}" Model - db.define_table('Dept', Field('DeptCode'), Field('DeptName'), primarykey=['DeptCode']) Controller - def index(): form = form=crud.update(db.Dept,db.Dept(db.Dept.DeptCode=='J12')) return dict(form=form) On Feb 9, 11:46 am, Niphlod wrote: > uhm, this is the relevant part for the form I was asking for > > value="ce992b3a79f9c18f92ec284b9bd443af"> type="hidden" value="Employee/{'EmployeeCode': > Decimal('61339')}"> > > for the "session" , just put {{=BEAUTIFY(session)}} into the template and > watch the keys > > Here the strange part is that it seems that employee code is not an integer > as defined into the model but a decimal. I don't know if this is the actual > problem, but it is different from the "normal" way. > > Waiting for the session data to see if formkey is different or equal, that > is the problem I was addressing in the previous message.
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
*Movuca goals:* *Everybody should be able to use it for free* - Use it for creating sites, blogs and social networks (free or commercial) *Everybody can sell it as a service* - Use it to offer Movuca based websites as a service - Use it for developing websites for customers *Everybody can extend, create plugins and add functionalities or plug in to another apps* - If used to deploy a website for you or client, free or commercial I dont care about modifications, you can keep it as a secret (because it can have your own business logic) *NOBODY can create or offer a commercial or closed source Movuca based "platform", I mean, you can't take the source code to create and distribute a "XPTO Social CMS engine"* - If you want to create it, *you will need to share your source code and modifications*! *My personal goals:* - Offer an open source CMS platform for web2py community. - Create a community around this solution - Have many contributors and a lot of people helping to code, document and improve the project - I will use it to create sites for my clients and offer this as a service (anybody will be able to do the same) I really dont care if big companies do not want to use it because of the license, this project targets *free-lancers, small companies, open groups and non-profits*. Big companies, experienced developers and people who want to raise billions of dollars with software can create their own solutions (even looking at Movuca code to copy some ideas). My target is not the big ones, I want to have it as open source, but at the same time protected to be always open source as a platform (as a product or service I don't care about the use) If my goal was to make money with this, I would not released it as open source, but I really want contributors, feedbacks and I also wanted to create a good web2py application to be reference for developers and to be included in the hall of good web2py appliances. Many people wants create a CMS, I invite everyone to bring their ideas to Movuca and we can create a killer general purpose CMS. Which license fits better for this? -- Bruno Rocha [http://rochacbruno.com.br]
[web2py] Re: Update legacy table using primarykey failed
that seems a float vs decimal problem bottom line, I didn't get what is not working right now ? PS: post table definition in "raw sql", model of the table as in the models.py, and controller, so I can at least try to reproduce with sqlite or postgres (again, sorry but I don't have DB2 or MSSQL test db available)
Re: [web2py] Re: keep shared objects permanently in RAM: Is it possible ?
Thanks for that Michele ! That is a nice trick for sharing information with different processes reducing to the minimum the FS IO... It still has the IO bottleneck of read/write from/to file compare with real data permanent in memory... but still a valid approach... On Thu, Feb 9, 2012 at 12:58 AM, Michele Comitini < michele.comit...@gmail.com> wrote: > You can reach a very high level of > parallelism with lower dead-locking probability than with java > threads. > any source about that ? (any paper, benchmarks etc...) -- Sebastian E. Ovide
Re: [web2py] DAL speed - an idea
Yes, that is the basis of what I am suggesting. There is not currently such a thing; there is something called 'select_raw' implemented in the GoogleDataStore adapter, but not in anything else, and it isn't exactly what I am proposing. To elaborate: Assume the table is defined as follows: reftable = db.define_table('reftable', Field('a', string)) table = db.define_table('table', Field('b', reftable)) In my case, I need to pull all the records (60,000) from the database to compute some aggregation which I cannot compute using sql. There are two alternatives here: r1 = db().select(table.ALL) # takes > 6 seconds r2 = db.executesql(db._select(table.ALL)) # takes ~0.1sec The records returned in the first instance are much richer; they have record chasing (e.g. I can do r1[0].b.a to select through the foreign key), they have methods like r1[0].update_record() and r1[0].delete_record(), and other nice stuff. However, for this use, I don't need the additional records, and I do need the speed, so I would rather use r2. However, r2 is not a direct replacement -- it doesn't have the column names. If I use r3 = db.executesql(db._select(table.ALL), as_dict=True) # still takes ~0.1sec I can do r3[0]['b'] but I cannot do r3[0].b; and it takes a lot more memory than r2. A suggestion: add another parameter, processor=... which, if available, will be called with the db.connection.cursor, returning a function, through which each routine will be passed; example def named_tuple_process(name, description): from collections import namedtuple fields = ' '.join([x[0] for x in description]) return namedtuple(name, fields) r4 = db.executesql(db._select(table.ALL), process=lambda x: named_tuple_process('tablerec', x)) r4[0].b # will now work; not a full replacement, but good enough for many uses. In fact, you can do that externally - r4 = db.executesql(db._select(table.ALL)) f = named_tuple_process('tablerec', db._adapter.cursor.description) r4 = [f(x) for x in r4] But this requires reaching into the internals of the db adapter. Finally, I propose to define x.raw_select(*args) to do: db.executesql(x._select(*args)) which would make this a relatively clean replacement.
[web2py] Re: option to move smartgrid buttons to the left side
Hi Peter... I put a simple smartgrid together, with a longer text field... so this one doesn't scroll horizontally for me. I'm not sure if it's something that we did on css or somewhere, but i noticed it worked on ipad as it should... here is the link: http://w2p.thanedev.com/test2/test/test/test1 Thanks, Adnan
Re: [web2py] uwsgi configuration: why many lines in /root/var/log/uwsgi-python/web2py log : routing 0 routes 0 ?
I installed uwsgi via: add-apt-repository ppa:uwsgi/release So there's nothing I can do to turn this logging off?. Thanks.
[web2py] Re: Update legacy table using primarykey failed
Thank you the help. So far, I found... - Ver 1.99.2 doesn't support update for primarykey - Ver 1.99.4 does support update for primarykey if it's string So this will fail. If it works for posgres and maybe problem with db2/ mssql. (I use DAL: mssql2). From the syntax error, it's ignore the 'integer' from define_table and always tried with string... Table on MSSQL --- CREATE TABLE [dbo].[Test]( [mykey] [int] NOT NULL, [myvalue] [varchar](50) NULL, CONSTRAINT [PK_Test] PRIMARY KEY CLUSTERED ( [mykey] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] Add Record like 111|AAA Model - db.define_table('Test', Field('mykey','integer'), Field('myvalue'), primarykey=['mykey']) Controller - def index(): form=crud.update(db.Test,db.Test(db.Test.mykey==111)) return dict(form=form) TRACEBACK - SyntaxError: user is tampering with form's record_id: {'mykey': '111'} != {'mykey': 111} On Feb 9, 1:58 pm, Niphlod wrote: > that seems a float vs decimal problem > > bottom line, I didn't get what is not working right now ? > > PS: post table definition in "raw sql", model of the table as in the > models.py, and controller, so I can at least try to reproduce with sqlite > or postgres (again, sorry but I don't have DB2 or MSSQL test db available)
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
On Thu, Feb 9, 2012 at 4:34 PM, Bruce Wade wrote: > > GPL = Doesn't want anyone making money off their code and forces people to > recommit their code. This is good because everyone gets the code, bad > because you don't have a choice. > This is not completely true. GPL has nothing to do with making money. GPL do not forces anyone to recommit their code. It only says that if you make a GPL derivative, you have to offer a way to get the source code with the modification (only to your customers that received the software directly from you). You don't even need to publish it, just give it to your customers (of course, your customers can give the code to others). So, if you just use GPL for a web application, and you don't distribute that application, you don't have to give the code to anyone, you can keep it closed with all your "trade secrets". This will be the use case for most users of Movuca, so they wouldn't have to worry on republishing code. GPL only protect against anyone wishing to take open source code for free, closing it and sell binary only copies. That really hurts free software in this case. Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
Yes exactly what I want. I should go with GPL3 or LGPL3 ? On Thu, Feb 9, 2012 at 6:34 PM, Mariano Reingart wrote: > > This is not completely true. > > GPL has nothing to do with making money. > GPL do not forces anyone to recommit their code. It only says that if > you make a GPL derivative, you have to offer a way to get the source > code with the modification (only to your customers that received the > software directly from you). > You don't even need to publish it, just give it to your customers (of > course, your customers can give the code to others). > > So, if you just use GPL for a web application, and you don't > distribute that application, you don't have to give the code to > anyone, you can keep it closed with all your "trade secrets". > This will be the use case for most users of Movuca, so they wouldn't > have to worry on republishing code. > > GPL only protect against anyone wishing to take open source code for > free, closing it and sell binary only copies. > That really hurts free software in this case. -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] DAL speed - an idea
"In my case, I need to pull all the records (60,000) from the database to compute some aggregation which I cannot compute using sql" Are you familiar with window functions in SQL? I've never met an aggregation need that couldn't be met with clever use of windows...
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
> > *Everybody can extend, create plugins and add functionalities or plug in > to another apps* > - If used to deploy a website for you or client, free or commercial I dont > care about modifications, you can keep it as a secret (because it can have > your own business logic) > > *NOBODY can create or offer a commercial or closed source Movuca based > "platform", I mean, you can't take the source code to create and distribute > a "XPTO Social CMS engine"* > - If you want to create it, *you will need to share your source code and > modifications*! > Out of curiosity, why are you OK with the first use case (i.e., keep modifications private when deploying on a server for commercial purposes) but not the second (i.e., keep modifications private when distributing via other means for commercial purposes)? In both cases, someone is making money and keeping any modifications they have made private (i.e., not contributing back). I'm not arguing that one or the other should be allowed or prohibited, just curious about the distinction between these cases. Anthony
Re: [web2py] DAL speed - an idea
I've been thinking about something like this as well. Instead of a separate select_raw() method, maybe we can just add a raw=True|False argument to the existing select() method. I like the namedtuple idea as well (I think some adapters already provide that as an option -- e.g., psycopg2). Anthony On Thursday, February 9, 2012 3:04:41 PM UTC-5, nick name wrote: > > Yes, that is the basis of what I am suggesting. > > There is not currently such a thing; there is something called > 'select_raw' implemented in the GoogleDataStore adapter, but not in > anything else, and it isn't exactly what I am proposing. > > To elaborate: > > Assume the table is defined as follows: > > reftable = db.define_table('reftable', Field('a', string)) > table = db.define_table('table', Field('b', reftable)) > > In my case, I need to pull all the records (60,000) from the database to > compute some aggregation which I cannot compute using sql. There are two > alternatives here: > > r1 = db().select(table.ALL) # takes > 6 seconds > > r2 = db.executesql(db._select(table.ALL)) # takes ~0.1sec > > The records returned in the first instance are much richer; they have > record chasing (e.g. I can do r1[0].b.a to select through the foreign key), > they have methods like r1[0].update_record() and r1[0].delete_record(), and > other nice stuff. > > However, for this use, I don't need the additional records, and I do need > the speed, so I would rather use r2. However, r2 is not a direct > replacement -- it doesn't have the column names. If I use > > r3 = db.executesql(db._select(table.ALL), as_dict=True) # still takes > ~0.1sec > > I can do r3[0]['b'] but I cannot do r3[0].b; and it takes a lot more > memory than r2. > > A suggestion: add another parameter, processor=... which, if available, > will be called with the db.connection.cursor, returning a function, through > which each routine will be passed; example > > def named_tuple_process(name, description): >from collections import namedtuple >fields = ' '.join([x[0] for x in description]) >return namedtuple(name, fields) > > r4 = db.executesql(db._select(table.ALL), process=lambda x: > named_tuple_process('tablerec', x)) > > r4[0].b # will now work; not a full replacement, but good enough for many > uses. > > In fact, you can do that externally - > > r4 = db.executesql(db._select(table.ALL)) > f = named_tuple_process('tablerec', db._adapter.cursor.description) > r4 = [f(x) for x in r4] > > But this requires reaching into the internals of the db adapter. > > Finally, I propose to define x.raw_select(*args) to do: > db.executesql(x._select(*args)) > > which would make this a relatively clean replacement. >
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
Example, I can use joomla to create commercial websites for my clients, also I can use it if I am a hosting provider to offer as a service "create site" tool. But I cant use Joomla to create a : *Bruno's joomla commercial platform* to compete with Joomla. I think if you are going to keep the code in your server the code is yours, but if you want to redistribute the platform, you have to contribute back to community. The problem is not money, the problem is using open source code to create commercial platforms and not contributing back to the community. Can I take web2py source and create "Bruno's commercial framework" ?? extend it and sell to my clients, keeping my improvements closed? On Thu, Feb 9, 2012 at 7:01 PM, Anthony wrote: > *Everybody can extend, create plugins and add functionalities or plug in >> to another apps* >> - If used to deploy a website for you or client, free or commercial I >> dont care about modifications, you can keep it as a secret (because it can >> have your own business logic) >> >> *NOBODY can create or offer a commercial or closed source Movuca based >> "platform", I mean, you can't take the source code to create and distribute >> a "XPTO Social CMS engine"* >> - If you want to create it, *you will need to share your source code and >> modifications*! >> > > Out of curiosity, why are you OK with the first use case (i.e., keep > modifications private when deploying on a server for commercial purposes) > but not the second (i.e., keep modifications private when distributing via > other means for commercial purposes)? In both cases, someone is making > money and keeping any modifications they have made private (i.e., not > contributing back). I'm not arguing that one or the other should be allowed > or prohibited, just curious about the distinction between these cases. > > Anthony > > > -- > mail from:GoogleGroups "web2py-developers" mailing list > make speech: web2py-develop...@googlegroups.com > unsubscribe: web2py-developers+unsubscr...@googlegroups.com > details : http://groups.google.com/group/web2py-developers > the project: http://code.google.com/p/web2py/ > official : http://www.web2py.com/ > -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
>From your description you are wanting to go with LGPL3. On Thu, Feb 9, 2012 at 1:21 PM, Bruno Rocha wrote: > Example, I can use joomla to create commercial websites for my clients, > also I can use it if I am a hosting provider to offer as a service "create > site" tool. > > But I cant use Joomla to create a : *Bruno's joomla commercial platform*to > compete with Joomla. > > I think if you are going to keep the code in your server the code is > yours, but if you want to redistribute the platform, you have to contribute > back to community. The problem is not money, the problem is using open > source code to create commercial platforms and not contributing back to the > community. > > Can I take web2py source and create "Bruno's commercial framework" ?? > extend it and sell to my clients, keeping my improvements closed? > > On Thu, Feb 9, 2012 at 7:01 PM, Anthony wrote: > >> *Everybody can extend, create plugins and add functionalities or plug in >>> to another apps* >>> - If used to deploy a website for you or client, free or commercial I >>> dont care about modifications, you can keep it as a secret (because it can >>> have your own business logic) >>> >>> *NOBODY can create or offer a commercial or closed source Movuca based >>> "platform", I mean, you can't take the source code to create and distribute >>> a "XPTO Social CMS engine"* >>> - If you want to create it, *you will need to share your source code >>> and modifications*! >>> >> >> Out of curiosity, why are you OK with the first use case (i.e., keep >> modifications private when deploying on a server for commercial purposes) >> but not the second (i.e., keep modifications private when distributing via >> other means for commercial purposes)? In both cases, someone is making >> money and keeping any modifications they have made private (i.e., not >> contributing back). I'm not arguing that one or the other should be allowed >> or prohibited, just curious about the distinction between these cases. >> >> Anthony >> >> >> -- >> mail from:GoogleGroups "web2py-developers" mailing list >> make speech: web2py-develop...@googlegroups.com >> unsubscribe: web2py-developers+unsubscr...@googlegroups.com >> details : http://groups.google.com/group/web2py-developers >> the project: http://code.google.com/p/web2py/ >> official : http://www.web2py.com/ >> > > > > -- > > Bruno Rocha > [http://rochacbruno.com.br] > > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Odd hasattr(session, 'blah'). Don't understand it.
In an index function I do something like session[request.controller].something = 'foo' This raises a key error exception on the first visit to the controller after restarting the browser. Session can't find the controller name, so I can't add an attribute to it. So I need to initialize the session, but not clobber it if already set. After several hours this puzzling behavior emerged: print session # request.controller not there, as expected. # nothing but auth print hasattr(session, str(request.controller)) # Prints True. ## Previous result not expected!! Why?? print request.controller in session # Prints False, as expected session[request.controller] = {} print hasattr(session, str(request.controller)) # Prints True ## As expected this time. print request.controller in session # Prints True, as expected print session[request.controller] # Prints {}, as expected Can someone tell me why hasattr(session, str(request.controller)) returned true when request.controller was not an attribute of session? Thanks, Cliff Kachinske
[web2py] Re: option to move smartgrid buttons to the left side
Yes, I can not move right on your app. But surely the solution is to find out your css's problem with android rather than move the buttons to the left. There might be other reasons for the having the buttons on the left, but buttons on the right work fine with android if one can move right. Peter On Feb 9, 8:05 pm, Adi wrote: > Hi Peter... > > I put a simple smartgrid together, with a longer text field... so this one > doesn't scroll horizontally for me. I'm not sure if it's something that we > did on css or somewhere, but i noticed it worked on ipad as it should... > > here is the link:http://w2p.thanedev.com/test2/test/test/test1 > > Thanks, > Adnan
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
Bruno, You already wrote it: It is the Movuca License. :-) Ricardo 2012/2/9 Bruno Rocha > > *Movuca goals:* > > *Everybody should be able to use it for free* > - Use it for creating sites, blogs and social networks (free or commercial) > > *Everybody can sell it as a service* > - Use it to offer Movuca based websites as a service > - Use it for developing websites for customers > > *Everybody can extend, create plugins and add functionalities or plug in > to another apps* > - If used to deploy a website for you or client, free or commercial I dont > care about modifications, you can keep it as a secret (because it can have > your own business logic) > > *NOBODY can create or offer a commercial or closed source Movuca based > "platform", I mean, you can't take the source code to create and distribute > a "XPTO Social CMS engine"* > - If you want to create it, *you will need to share your source code and > modifications*! > > *My personal goals:* > > - Offer an open source CMS platform for web2py community. > - Create a community around this solution > - Have many contributors and a lot of people helping to code, document and > improve the project > - I will use it to create sites for my clients and offer this as a service > (anybody will be able to do the same) > > I really dont care if big companies do not want to use it because of the > license, this project targets *free-lancers, small companies, open groups > and non-profits*. Big companies, experienced developers and people who > want to raise billions of dollars with software can create their own > solutions (even looking at Movuca code to copy some ideas). My target is > not the big ones, I want to have it as open source, but at the same time > protected to be always open source as a platform (as a product or service I > don't care about the use) > > If my goal was to make money with this, I would not released it as open > source, but I really want contributors, feedbacks and I also wanted to > create a good web2py application to be reference for developers and to be > included in the hall of good web2py appliances. > > Many people wants create a CMS, I invite everyone to bring their ideas to > Movuca and we can create a killer general purpose CMS. > > Which license fits better for this? > > > -- > > Bruno Rocha > [http://rochacbruno.com.br] > >
Re: [web2py] Odd hasattr(session, 'blah'). Don't understand it.
session is an Storage, Storages always return an attribute, defaults to None. You do not have to always access session objects by keys, you can do it by attribute and it will always return an object, even if the object does not exists. examples my_var = getattr(session, request.controller) Even when you have nothing in session, it will return an object with value "None" >>> from gluon.storage import Storage >>> session = Storage() >>> my_var = getattr(session, "blablabla") >>> my_var >>> print my_var None >>> session.anything = "blah" >>> print getattr(session, "anything") blah >>> print session.anything blah >>> print session["anything"] blah >>> print session.banana None >>> print session["ohohohoho"] None >>> print getattr(session, "jsdnfgkjsdnfjkds") None >>> On Thu, Feb 9, 2012 at 7:38 PM, Cliff wrote: > In an index function I do something like > session[request.controller].something = 'foo' > > This raises a key error exception on the first visit to the controller > after restarting the browser. Session can't find the controller name, > so I can't add an attribute to it. So I need to initialize the > session, but not clobber it if already set. > > After several hours this puzzling behavior emerged: > > print session # request.controller not there, as expected. > # nothing but auth > print hasattr(session, str(request.controller)) # Prints True. > ## Previous result not expected!! Why?? > print request.controller in session # Prints False, as expected > session[request.controller] = {} > print hasattr(session, str(request.controller)) # Prints True > ## As expected this time. > print request.controller in session # Prints True, as expected > print session[request.controller] # Prints {}, as expected > > Can someone tell me why hasattr(session, str(request.controller)) > returned true when request.controller was not an attribute of session? > > Thanks, > Cliff Kachinske > > -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
On Thu, Feb 9, 2012 at 7:52 PM, R. Strusberg wrote: > Bruno, > > You already wrote it: It is the Movuca License. :-) Legally, can I use this as a license? it has any matter? or I need to choose an existing license (I dont know how this things works, do I need to register it?) -- Bruno Rocha [http://rochacbruno.com.br]
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
For this case, LGPL3 or GPL3 are almost indistinguishable in this context (web app) AFAIK, LGPL3 is better if you want that subparts of Movuca being used/distributed in other contexts (i.e., with other closed source CMS, or with other open source software MIT/BSD licensed) With web2py it is more complicated to say if you can take it's source and create "Bruno's commercial framework". I guess neither with GPL nor with LGPL3 you could do that. What you can do is use web2py gluon libraries to build third-party closed-source apps, or use web2py to server closed source web-apps, but not a web2py propietary derivative. Best regards, Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Thu, Feb 9, 2012 at 6:28 PM, Bruce Wade wrote: > From your description you are wanting to go with LGPL3. > > > On Thu, Feb 9, 2012 at 1:21 PM, Bruno Rocha wrote: >> >> Example, I can use joomla to create commercial websites for my clients, >> also I can use it if I am a hosting provider to offer as a service "create >> site" tool. >> >> But I cant use Joomla to create a : Bruno's joomla commercial platform to >> compete with Joomla. >> >> I think if you are going to keep the code in your server the code is >> yours, but if you want to redistribute the platform, you have to contribute >> back to community. The problem is not money, the problem is using open >> source code to create commercial platforms and not contributing back to the >> community. >> >> Can I take web2py source and create "Bruno's commercial framework" ?? >> extend it and sell to my clients, keeping my improvements closed? >> >> On Thu, Feb 9, 2012 at 7:01 PM, Anthony wrote: Everybody can extend, create plugins and add functionalities or plug in to another apps - If used to deploy a website for you or client, free or commercial I dont care about modifications, you can keep it as a secret (because it can have your own business logic) NOBODY can create or offer a commercial or closed source Movuca based "platform", I mean, you can't take the source code to create and distribute a "XPTO Social CMS engine" - If you want to create it, you will need to share your source code and modifications! >>> >>> >>> Out of curiosity, why are you OK with the first use case (i.e., keep >>> modifications private when deploying on a server for commercial purposes) >>> but not the second (i.e., keep modifications private when distributing via >>> other means for commercial purposes)? In both cases, someone is making money >>> and keeping any modifications they have made private (i.e., not contributing >>> back). I'm not arguing that one or the other should be allowed or >>> prohibited, just curious about the distinction between these cases. >>> >>> Anthony >>> >>> >>> -- >>> mail from:GoogleGroups "web2py-developers" mailing list >>> make speech: web2py-develop...@googlegroups.com >>> unsubscribe: web2py-developers+unsubscr...@googlegroups.com >>> details : http://groups.google.com/group/web2py-developers >>> the project: http://code.google.com/p/web2py/ >>> official : http://www.web2py.com/ >> >> >> >> >> -- >> >> Bruno Rocha >> [http://rochacbruno.com.br] >> > > > > -- > -- > Regards, > Bruce Wade > http://ca.linkedin.com/in/brucelwade > http://www.wadecybertech.com > http://www.warplydesigned.com > http://www.fitnessfriendsfinder.com
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
> > Example, I can use joomla to create commercial websites for my clients, > also I can use it if I am a hosting provider to offer as a service "create > site" tool. > > But I cant use Joomla to create a : *Bruno's joomla commercial platform*to > compete with Joomla. > > I think if you are going to keep the code in your server the code is > yours, but if you want to redistribute the platform, you have to contribute > back to community. The problem is not money, the problem is using open > source code to create commercial platforms and not contributing back to the > community. > > Can I take web2py source and create "Bruno's commercial framework" ?? > extend it and sell to my clients, keeping my improvements closed? > No, you can't do that with web2py because of the LGPL license, but you could do that with Django, Flask, Pyramid, and Rails. I guess that still doesn't answer the "why" question. If it's OK to use open source code to create a commercial website (perhaps even a SaaS model that is essentially a "platform") without contributing code back to the community, then why is it not OK to use open source code to create a commercial "platform"? Why should one warrant code contribution back to the community but not the other? Neither the AGPL folks nor the BSD/MIT folks seem to think there should be a distinction (AGPL allows neither use case, and BSD/MIT allow both). Only GPL really makes the distinction, and the FSF folks seem to think that was simply an unfortunate oversight rather than a principled position (hence the AGPL). For what it's worth, most of the Django and Rails based CMSes are BSD/MIT licensed (as are Django and Rails themselves). I'm not sure what their experience has been getting contributions, or if they have in any way been hampered by commercial forks (or if there are even any commercial forks). Anthony
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
I bet you'll get better luck in courts if you use a well-known licence. GPL has been written by lawyers and it has some enforcement jurisprudence right now. Mariano Reingart http://www.sistemasagiles.com.ar http://reingart.blogspot.com On Thu, Feb 9, 2012 at 6:56 PM, Bruno Rocha wrote: > > > On Thu, Feb 9, 2012 at 7:52 PM, R. Strusberg wrote: >> >> Bruno, >> >> You already wrote it: It is the Movuca License. :-) > > > Legally, can I use this as a license? it has any matter? or I need to choose > an existing license > > (I dont know how this things works, do I need to register it?) > > > > -- > > Bruno Rocha > [http://rochacbruno.com.br] >
[web2py] Re: maybe minor bug or just documentation
On Thursday, February 9, 2012 1:28:28 PM UTC-5, Lewis wrote: > > Then why did web2py fail with a run time error? Or why wasn't the run > time error trapped? Maybe because I had requires on the same table > for a different constraint? > I assume there must be an explicit "requires" attribute set for that field somewhere, so the automatic setting of "requires" isn't happening. You'll have to show more code. > It doesn't look good when visitors to your site see the web2py error > ticket page. You can generate friendly error pages -- see http://web2py.com/books/default/chapter/29/4#Routes-on-error. The error page can be a static file, or a dynamically generated page. In the latter case, it might be safer to have the error handler in a separate error handling application -- that way if the error happens to be in a model file of your main app, it won't prevent the error handler from being reached. Anthony
[web2py] Customize SQLFORM.grid
Hi, In the old framework I would just query the database and loop through the values manually creating the HTML table etc... Which allows me to do something like this: types = { 'bp': 'Product Bonus', 'sb': 'Sponsor Bonus', } for row in rows: Type types[row.type] Is there a way to use SQLFORM.grid and tell it to display a dictionary value based on the key stored in the database? -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
I think it's good for people to advocate for their license preferences. I also think the discussion should be based on facts, so I would like to offer some observations about statements that make me uncomfortable. > The freedom in software also comes the freedom of choice, to either give > back or not, that is why a lot of people prefer the BSD thinking over the > GPL thinking. I don't know what is meant by "a lot of people." But there are some statistics that seem to indicate a lot more people prefer the GPL. As of June 2009, the GPL licenses accounted for ~ 65% usage. BSD accounted for 6.3. Now I realize that's more than 30 months ago, or two centuries in internet years. Still, I doubt there has been a big swing in the intervening time. You can read more about it here: http://www.blackducksoftware.com/news/releases/2009-06-30 If there is later data that shows otherwise I would be happy to see it. > GPL = Doesn't want anyone making money off their code... No. If this were anywhere close to true there would be mobs of angry kernel developers protesting the activities of companies like Red Hat and IBM, both companies making tons of money off GPL code. Got any? Also, if there is any credible evidence that any author of the GPL has made a statement like that I would be happy to see it. On Feb 9, 2:34 pm, Bruce Wade wrote: > I can see your point even though I don't 100% agree with it. I write most > of my code opensource, however I also have been writing software for a > living for around 14 years so sometimes we don't have the choice between > open and closed source. > > We also can't expect only people interested in free software development to > use our software. Considering as you just said the software is there for > others to use and if they add more features faster then you and don't give > you the features you also can't get upset. Also sharing code and sharing > knowledge are not always one and the same. > > The freedom in software also comes the freedom of choice, to either give > back or not, that is why a lot of people prefer the BSD thinking over the > GPL thinking. > > BSD = Doesn't care if someone makes money off their code or not, they just > want people using their code. They also have the choice to release their > code or not. > GPL = Doesn't want anyone making money off their code and forces people to > recommit their code. This is good because everyone gets the code, bad > because you don't have a choice. > > I am more of a BSD thinker. > > On Thu, Feb 9, 2012 at 11:04 AM, Wikus van de Merwe < > > > > > > > > > > dupakrop...@googlemail.com> wrote: > > What I see you are trying to say is that by keeping the code secret one > > gains a temporary advantage over the competition. That might be true. But > > this is the way of thinking coming from the proprietary software > > philosophy. How much will I loose by making the software free? If this is > > your line of thinking, then maybe writing free software is not what you > > want to do. > > > Because at the core of the free software movement is a believe, that > > sharing the code would make the world better. Free software is not here to > > make us rich. Is not here to make our software easy to (ab)use by business. > > It is here to preserve out freedoms. It represent an ethical view that > > sharing knowledge is more important than making money. If you don't agree > > with that, then the free software is probably not for you. > > > Everyone writing free software should understand that the old business > > models of proprietary software based on secrecy doesn't apply here. The > > value is in the collaborative effort to improve the shared code. It > > shouldn't bother you when somebody else builds on your code and gets ahead > > of you in terms of features, because this is what you wanted when you > > decided to write the free software! Instead of complaining that this puts > > you out of the business you should rather seek for opportunities to > > collaborate and write more code together which would be good for the > > business too. And if you want to compete, compete in solving new problems > > (not the ones that have been already solved, there is no need to duplicate > > the works of others) and charge your customers for doing that. > > > Now, don't get me wrong. I admit it is not as easy to build a business > > around the free software as it is in case of proprietary software. But it > > is not impossible or even especially hard. And is much more fun. This is > > why we shouldn't give up trying new ways just because they are different to > > what we know from the proprietary world. On the rise of cloud platforms I > > see future for the AGPL too. > > -- > -- > Regards, > Bruce > Wadehttp://ca.linkedin.com/in/brucelwadehttp://www.wadecybertech.comhttp://www.warplydesigned.comhttp://www.fitnessfriendsfinder.com
Re: [web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
Making money off the code, meaning you can't go sell the code. With BSD code you can. I said a lot of people, I didn't say MORE people. With BSD there is also a lot of people using it that don't announce they are using the BSD based software. On Thu, Feb 9, 2012 at 2:46 PM, Cliff wrote: > I think it's good for people to advocate for their license > preferences. > > I also think the discussion should be based on facts, so I would like > to offer some observations about statements that make me > uncomfortable. > > > The freedom in software also comes the freedom of choice, to either give > > back or not, that is why a lot of people prefer the BSD thinking over the > > GPL thinking. > > I don't know what is meant by "a lot of people." But there are some > statistics that seem to indicate a lot more people prefer the GPL. As > of June 2009, the GPL licenses accounted for ~ 65% usage. BSD > accounted for 6.3. Now I realize that's more than 30 months ago, or > two centuries in internet years. Still, I doubt there has been a big > swing in the intervening time. > > You can read more about it here: > http://www.blackducksoftware.com/news/releases/2009-06-30 > > If there is later data that shows otherwise I would be happy to see > it. > > > GPL = Doesn't want anyone making money off their code... > > No. If this were anywhere close to true there would be mobs of angry > kernel developers protesting the activities of companies like Red Hat > and IBM, both companies making tons of money off GPL code. Got any? > > Also, if there is any credible evidence that any author of the GPL has > made a statement like that I would be happy to see it. > > > > On Feb 9, 2:34 pm, Bruce Wade wrote: > > I can see your point even though I don't 100% agree with it. I write most > > of my code opensource, however I also have been writing software for a > > living for around 14 years so sometimes we don't have the choice between > > open and closed source. > > > > We also can't expect only people interested in free software development > to > > use our software. Considering as you just said the software is there for > > others to use and if they add more features faster then you and don't > give > > you the features you also can't get upset. Also sharing code and sharing > > knowledge are not always one and the same. > > > > The freedom in software also comes the freedom of choice, to either give > > back or not, that is why a lot of people prefer the BSD thinking over the > > GPL thinking. > > > > BSD = Doesn't care if someone makes money off their code or not, they > just > > want people using their code. They also have the choice to release their > > code or not. > > GPL = Doesn't want anyone making money off their code and forces people > to > > recommit their code. This is good because everyone gets the code, bad > > because you don't have a choice. > > > > I am more of a BSD thinker. > > > > On Thu, Feb 9, 2012 at 11:04 AM, Wikus van de Merwe < > > > > > > > > > > > > > > > > > > > > dupakrop...@googlemail.com> wrote: > > > What I see you are trying to say is that by keeping the code secret one > > > gains a temporary advantage over the competition. That might be true. > But > > > this is the way of thinking coming from the proprietary software > > > philosophy. How much will I loose by making the software free? If this > is > > > your line of thinking, then maybe writing free software is not what you > > > want to do. > > > > > Because at the core of the free software movement is a believe, that > > > sharing the code would make the world better. Free software is not > here to > > > make us rich. Is not here to make our software easy to (ab)use by > business. > > > It is here to preserve out freedoms. It represent an ethical view that > > > sharing knowledge is more important than making money. If you don't > agree > > > with that, then the free software is probably not for you. > > > > > Everyone writing free software should understand that the old business > > > models of proprietary software based on secrecy doesn't apply here. The > > > value is in the collaborative effort to improve the shared code. It > > > shouldn't bother you when somebody else builds on your code and gets > ahead > > > of you in terms of features, because this is what you wanted when you > > > decided to write the free software! Instead of complaining that this > puts > > > you out of the business you should rather seek for opportunities to > > > collaborate and write more code together which would be good for the > > > business too. And if you want to compete, compete in solving new > problems > > > (not the ones that have been already solved, there is no need to > duplicate > > > the works of others) and charge your customers for doing that. > > > > > Now, don't get me wrong. I admit it is not as easy to build a business > > > around the free software as it is in case of proprietary software. But > it > > > is not impossible or even especial
[web2py] Re: Customize SQLFORM.grid
Never mind figured it out. types = { 'bp': 'Product Bonus', 'sb': 'Sponsor Bonus', } db.cash_journal.transaction_type.represent = lambda transaction_type,row: types[transaction_type] ucashHistoryGrid = SQLFORM.grid( db.cash_journal, paginate=10, deletable=False, editable=False, details=False, csv=True, formname='ucash-history', ) On Thu, Feb 9, 2012 at 2:35 PM, Bruce Wade wrote: > Hi, > > In the old framework I would just query the database and loop through the > values manually creating the HTML table etc... > > Which allows me to do something like this: > types = { > 'bp': 'Product Bonus', > 'sb': 'Sponsor Bonus', > } > > for row in rows: > > Type > types[row.type] > > > > Is there a way to use SQLFORM.grid and tell it to display a dictionary > value based on the key stored in the database? > -- > -- > 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] restricting the options in drop-down menu based on another drop-down menu value
Let's say the model has three tables, called country, cities and customers that are defined like: db.define_table('continents', Field('name'), ) db.define_table('countries', Field('name'), Field('continent', db.continents), ) db.define_table('customers', Field('name'), Field('country', db.countries), Field('continent', db.continents), ) Now if I check the "Database Administration", how can I set up the customers table such that when I am inserting a record in the customers table, if I select a country, the continent the country is in is automatically selected? Under another scenario, imagine we first select the continent, then the country and then enter the name of the customer, how can I set up the model such that when the continent is selected, only the countries in that particular continent are available to be selected? I am imagining that the counties and continents in the customers table and the countries table are drop-down menus. Any help would be appreciated. Thanks! =)
Re: [web2py] restricting the options in drop-down menu based on another drop-down menu value
You have to do this with Javascript http://176.34.12.39/welcome/en/static/js/location.js That is how I am handling the situation where select a continent only the countries for that continent show in the select box. On Thu, Feb 9, 2012 at 4:53 PM, shartha wrote: > Let's say the model has three tables, called country, cities and > customers that are defined like: > > db.define_table('continents', > Field('name'), > ) > > db.define_table('countries', > Field('name'), > Field('continent', db.continents), > ) > > db.define_table('customers', > Field('name'), > Field('country', db.countries), > Field('continent', db.continents), > ) > > Now if I check the "Database Administration", how can I set up the > customers table such that when I am inserting a record in the > customers table, if I select a country, the continent the country is > in is automatically selected? > > Under another scenario, imagine we first select the continent, then > the country and then enter the name of the customer, how can I set up > the model such that when the continent is selected, only the countries > in that particular continent are available to be selected? > > I am imagining that the counties and continents in the customers table > and the countries table are drop-down menus. > > Any help would be appreciated. Thanks! =) -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com
[web2py] Re: [w2py-dev] Re: Movuca - Social CMS beta 0.1
> > I don't know what is meant by "a lot of people." But there are some > statistics that seem to indicate a lot more people prefer the GPL. As > of June 2009, the GPL licenses accounted for ~ 65% usage. BSD > accounted for 6.3. Now I realize that's more than 30 months ago, or > two centuries in internet years. Still, I doubt there has been a big > swing in the intervening time. > > You can read more about it here: > http://www.blackducksoftware.com/news/releases/2009-06-30 > According to the latest data ( http://osrc.blackducksoftware.com/data/licenses/index.php), there has in fact been a trend toward the more permissive licences (i.e., BSD, MIT, Apache, etc.), which now account for at least 26% of projects, with GPL dropping to only 57%. I think it also varies by type of software -- for example, at least in the Python and Ruby web development world, I think most frameworks and related tools tend to have permissive licenses like BSD and MIT. GPL might be more common for end-user software. Anthony
[web2py] The web2py version
Hi, I know I have been posting a lot of questions in this group, here is why: http://176.34.12.39 The port is about 90% complete now after 1.5 months of work :D Have removed 100s of lines of code in some parts of the application. Let me know what you think so far. The database is just junk data right now. -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com