[web2py] Re: Unsigned int in DAL
I know 2**31, I meant the value: 2147483648 :) And while the IS_INT_IN_RANGE is fine for negative value (I am already using it) that does not change the fact that is the column is not set as unsigned, 2147483648 can't be saved. For the deployment, no that's not a solution. We require à fully scripted solution that may be deployed by maintenance guys without knowledge of what they do at anytime. And the models evolve between updates. Just out of curiosity, why unsigned it not a default and simple parameter ? (handled only if the backend handles) Le vendredi 16 novembre 2012 21:46:09 UTC+1, Niphlod a écrit : > > > > On Friday, November 16, 2012 9:23:33 PM UTC+1, Joseph.Piron wrote: >> >> No I can't, here I have to stock and let the user enter 2**31 and not >> 2**31-1 >> As everything else is possible, shouldn't it be possible to add a >> aprameter to the field constructor to set unsigned ? >> That would be really handy in situation such as mine where I have to >> deploy the solution on many servers. >>> >>> >>> 2**31 is not even allowed in a normal 'integer' field. That is a math > notation not supported and requires a whole different validation (and > parsing). > > What we are saying is that : > a) if you place a requires=IS_INT_IN_RANGE(0) there's no way any user can > enter "-12" and submit that value, no matter what the underlying column > type is set on the db > b) you can alter the column type "a posteriori" and web2py will be happy > with that even if your model specifies 'integer' > > PS: c) > - deploy your app to the 1st server > - take the sql.log you can find in the databases/ folder > - alter the column format as you wish in the declaration > - execute those statements on all the other servers > - deploy your app with migrate=False (which you should do in any case if > your model doesn't change) > --
[web2py] Re: Unsigned int in DAL
No I can't, here I have to stock and let the user enter 2**31 and not 2**31-1 As everything else is possible, shouldn't it be possible to add a aprameter to the field constructor to set unsigned ? That would be really handy in situation such as mine where I have to deploy the solution on many servers. Le vendredi 16 novembre 2012 18:19:26 UTC+1, villas a écrit : > > I don't think that DAL has this field type. > You can use a validator to make sure the integer is positive. > See IS_INT_IN_RANGE and IS_EXPR in the online book. > > > On Friday, November 16, 2012 4:12:45 PM UTC, Joseph.Piron wrote: >> >> Hi all! >> >> I have quite a problematic issue, I would like to know how to define a >> Field as unsigned in the DAL ? >> I tested: >> Field('triggerValue', 'unsigned integer', requires=IS_NOT_EMPTY(),notnull >> =True), >> and >> Field('triggerValue', 'integer', unsigned=True, requires=IS_NOT_EMPTY >> (), notnull=True), >> >> But it does not work. >> Could someone please enlighten me ? :D >> >> Thanks in advance !!! >> >> --
[web2py] Unsigned int in DAL
Hi all! I have quite a problematic issue, I would like to know how to define a Field as unsigned in the DAL ? I tested: Field('triggerValue', 'unsigned integer', requires=IS_NOT_EMPTY(),notnull =True), and Field('triggerValue', 'integer', unsigned=True, requires=IS_NOT_EMPTY(),notnull =True), But it does not work. Could someone please enlighten me ? :D Thanks in advance !!! --
[web2py] Re: Add count in db.parse_as_rest output
Isn't it possible ? :( Le lundi 23 avril 2012 10:26:35 UTC+2, Joseph.Piron a écrit : > > Hi guys! > > I am using the wonderful db.parse_as_rest function in my development and > like to ask if it is possible to push a modification in the trunk as as to > be able to go on without custom code maintenance :) > For paging purposes, I would need the output of this function to contain > the total number of records returned by the request (before limits > applies). Fortunately, this is already computed by the function: > if i==len(tags) and table: > ofields = vars.get('order',db[table]._id.name).split( > '|') > try: > orderby = [db[table][f] if not f.startswith('~') > else ~db[table][f[1:]] for f in ofields] > except KeyError: > return Row({'status':400,'error':'invalid orderby' > ,'response':None}) > fields = [field for field in db[table] if field. > readable] > count = dbset.count() > try: > offset = int(vars.get('offset',None) or 0) > limits = (offset,int(vars.get('limit',None) or > 1000)+offset) > except ValueError: > Row({'status':400,'error':'invalid limits', > 'response':None}) > if count > limits[1]-limits[0]: > Row({'status':400,'error':'too many records', > 'response':None}) > try: > response = dbset.select(limitby=limits,orderby= > orderby,*fields) > except ValueError: > return Row({'status':400,'pattern':pattern, > 'error':'invalid path','response':None > }) > return Row({'status':200,'response':response,'pattern' > :pattern}) > > > > and so I would modify the last return to: > > return Row({'status':200,'response':response,'pattern' > :pattern,'count':count}) > > Would this be acceptable ? > > Thanks in advance !! >
[web2py] Add count in db.parse_as_rest output
Hi guys! I am using the wonderful db.parse_as_rest function in my development and like to ask if it is possible to push a modification in the trunk as as to be able to go on without custom code maintenance :) For paging purposes, I would need the output of this function to contain the total number of records returned by the request (before limits applies). Fortunately, this is already computed by the function: if i==len(tags) and table: ofields = vars.get('order',db[table]._id.name).split('|' ) try: orderby = [db[table][f] if not f.startswith('~') else ~db[table][f[1:]] for f in ofields] except KeyError: return Row({'status':400,'error':'invalid orderby', 'response':None}) fields = [field for field in db[table] if field.readable ] count = dbset.count() try: offset = int(vars.get('offset',None) or 0) limits = (offset,int(vars.get('limit',None) or 1000 )+offset) except ValueError: Row({'status':400,'error':'invalid limits', 'response':None}) if count > limits[1]-limits[0]: Row({'status':400,'error':'too many records', 'response':None}) try: response = dbset.select(limitby=limits,orderby= orderby,*fields) except ValueError: return Row({'status':400,'pattern':pattern, 'error':'invalid path','response':None}) return Row({'status':200,'response':response,'pattern': pattern}) and so I would modify the last return to: return Row({'status':200,'response':response,'pattern': pattern,'count':count}) Would this be acceptable ? Thanks in advance !!
[web2py] Validating row
Hi guys, I just wondered how I am supposed to add a row validator in db models ? I looked at the code of validate function but it seems each validator is only passed the value of the field it is bound to. I am looking for this as I have to validate the value of one field based on other fields value. Thanks in advance for your help :) !
[web2py] Content-type header for HTTP exception incorrectly set ?
Hi gents ! I was working on an extjs client intended to discuss with web2py when I stumbled upon this weird behaviour: with my client calling "PUT /defaut/api/alarms/1.json", I want the server to respond a 409 error code with good json return {success: false, errors: {...}} and use raise HTTP(409, {"success":False, "errors":{...}}) to generate this error. Unfortunately, even if the call has been done with a ".json", the content-type header of the response is set to "text/html" and thus, the code adds a at the end for a 4xx code (not for a 5xx code, which works for me). Shouldn't the content-type be set to text/json or something similar ? Thanks for your support !
[web2py] Re: Login form, can't login..
Ok, it seems it is Chrome related.. :| I tried with Firefox and Safari and they hit the server only once. Could someone please confirm he has the same problem with Chrome (build 18.0.8025.142) ?? Le lundi 2 avril 2012 15:31:23 UTC+2, Joseph.Piron a écrit : > > Hi all, > > I got another problem (today's not my day it seems.. :'( ) > > I am trying to login through ldap but can't and nailed down another > problem: > On a simple login form url "default/user/login?_next=/app/default/index" I > get the classic login html form but can't succeed to log in. > Indeed, I traced a bit the code and the problem seems to be in html.py: > > in class FORM, accept function, there is: > if self.session: > formkey = self.session.get('_formkey[%s]' % self.formname, > None) > # check if user tampering with form and void CSRF > if formkey != self.request_vars._formkey: > status = False > > and formkey is always different from self.request_vars._formkey. > I also get three times in this function for each click on the login > button, and the formkey changes and it seems that the value of the second > or third passage is kept and compared with the one defined in the first > call and written in the form. > So of course, I can't login. > > It this a well known bug waiting for a patch? > > Thanks in advance !! >
[web2py] Login form, can't login..
Hi all, I got another problem (today's not my day it seems.. :'( ) I am trying to login through ldap but can't and nailed down another problem: On a simple login form url "default/user/login?_next=/app/default/index" I get the classic login html form but can't succeed to log in. Indeed, I traced a bit the code and the problem seems to be in html.py: in class FORM, accept function, there is: if self.session: formkey = self.session.get('_formkey[%s]' % self.formname, None) # check if user tampering with form and void CSRF if formkey != self.request_vars._formkey: status = False and formkey is always different from self.request_vars._formkey. I also get three times in this function for each click on the login button, and the formkey changes and it seems that the value of the second or third passage is kept and compared with the one defined in the first call and written in the form. So of course, I can't login. It this a well known bug waiting for a patch? Thanks in advance !!
[web2py] Re: Routes.py parameter, rewrite rules and redirect
Ah, and another simple question, maybe dull.. :) Does the domains option have any use when web2py's app is served from a apache or nginx frontend by wsgi ? Le lundi 2 avril 2012 11:57:37 UTC+2, Joseph.Piron a écrit : > > Hi all, > > For one of my applications, I use web2py as a rest backend for a extjs > application. So, in order to redirect to this app, I have > def index(): > """ > example action using the internationalization operator T and flash > rendered by views/default/index.html or views/generic.html > """ > redirect(URL(a=request.application, c='static', f='index.html')) > > > The problem is I want to have only the server name in the url so I added a > routes.py with > routers = dict( > BASE = dict( > default_application = "webmoni", > applications = ['webmoni','admin'], > controllers = 'DEFAULT' > ) > ) > > but it seems that the redirect neglects the default_application removal > attempt from the url. > How can I achieve this ? (not to have > https://webmoni/webmoni/static/index.html as displayed url) > > Moreover, I did try the domains option but there were no way for me to get > access to the admin app? > Could anyone give an example with port 80 to app and 443 to admin using > domains option ? > > Thanks in advance !!! > >
[web2py] Routes.py parameter, rewrite rules and redirect
Hi all, For one of my applications, I use web2py as a rest backend for a extjs application. So, in order to redirect to this app, I have def index(): """ example action using the internationalization operator T and flash rendered by views/default/index.html or views/generic.html """ redirect(URL(a=request.application, c='static', f='index.html')) The problem is I want to have only the server name in the url so I added a routes.py with routers = dict( BASE = dict( default_application = "webmoni", applications = ['webmoni','admin'], controllers = 'DEFAULT' ) ) but it seems that the redirect neglects the default_application removal attempt from the url. How can I achieve this ? (not to have https://webmoni/webmoni/static/index.html as displayed url) Moreover, I did try the domains option but there were no way for me to get access to the admin app? Could anyone give an example with port 80 to app and 443 to admin using domains option ? Thanks in advance !!!
[web2py] Re: More Details on RESTful web2py?
Hmm quite the same question as David G: I use the auto pattern feature (really nice) but I don't see how to provide an index for a resource. Am I missing something ? Thanks ! On Aug 9, 12:11 am, David G wrote: > I have a similar question as Web2py Newbie. I want to return all the > rows from a table using a pattern like: > > /myapp/api/table > > I'm wondering if your answer for Newbie is specific to returning a > single comment with the id of bookmark.id? How would you code the GET > method to get all the comments? > > Thanks! > > On Jun 16, 6:43 am, Massimo Di Pierro > wrote: > > > > > > > > > Then you need to call > > > /myapp/api/as_rest/1.json > > > where "api" is the controller, "as_rest" is your function, "1" is the > > {bookmark.id}. > > > On Jun 16, 12:51 am, Web2py Newbie > > > wrote: > > > At the moment it is: > > > > @request.restful() > > > def as_rest(): > > > def GET(*args,**vars): > > > patterns = ['/{bookmarks.id}', > > > ''] > > > parsed = db.parse_as_rest(patterns,args,vars) > > > if parsed.status==200: return parsed.response.json() > > > else: > > > posts = db().select(db.bookmarks.ALL) > > > return response.render('posts/index.html', locals()) > > > > On Jun 16, 12:58 pm, Massimo Di Pierro > > > wrote: > > > > > please show us your code. > > > > > On Jun 15, 2:25 am, Web2py Newbie > > > > > wrote: > > > > > As a follow up: > > > > > > I want to use something like: > > > > > /myapp/api/show_comment/id > > > > > to show comment at id > > > > > and > > > > > /myapp/api/show_comment/ > > > > > To show all comments > > > > > > However, when I try this it complains ("invalid arguments"). I try to > > > > > test id against None, but id is apparently a server object. > > > > > Any ideas or do I just have to define all_comments?- Hide quoted text > > > > > - > > > - Show quoted text -
[web2py] Re: No generic.json support anymore ?
Ok.. works :) I didn't see it in the changelog sorry. On Aug 17, 3:54 pm, Anthony wrote: > There is a security risk with generic views (they expose all variables > returned in the dict by the controller action, including all fields in any > returned database selects, and sometimes developers > unintentionally/unknowingly return more than they want to explicitly > expose). You can enable some/all generic views for some/all requests by > specifying response.generic_patterns somewhere. It should be a list of globs > that match the controller/function.extension for which you want to enable > generic views. > > response.generic_patterns = [*] # will enable all generic views for all > requests > > response.generic_patterns = ['json'] # will enable generic.json (if you > put this in your controller or function, it will only enable it for that > controller/function) > > Note, the current 'welcome' app enables all generic views, but only for > local requests (there is a line in db.py that does this). > > Anthony > > > > > > > > On Wednesday, August 17, 2011 9:46:47 AM UTC-4, Joseph.Piron wrote: > > Hi guys, quite a weirdo right here :) > > > I was on web2py 1.95.2 and everything was fine with my applications in > > production. > > To stay put, I have deciced to uppgrade to the last one 1.98.2 and > > validate everything works.. and ... it doesn't .. :'( > > > I have a controller serving db information through a simple json > > service and now, well I call for example > >http://localhost/app/control/item.json > > it fails with the 404: invalid view (control/item.json). > > Or course I don't have any control/item.json as I'd like it to just > > use the generic.json.. > > > Can someone help me please ? Thanks !
[web2py] No generic.json support anymore ?
Hi guys, quite a weirdo right here :) I was on web2py 1.95.2 and everything was fine with my applications in production. To stay put, I have deciced to uppgrade to the last one 1.98.2 and validate everything works.. and ... it doesn't .. :'( I have a controller serving db information through a simple json service and now, well I call for example http://localhost/app/control/item.json it fails with the 404: invalid view (control/item.json). Or course I don't have any control/item.json as I'd like it to just use the generic.json.. Can someone help me please ? Thanks !
[web2py] Re: versioning and uploads
The one created in the application folder when using the web interface versioning option. Haven't even noticed the distro one. What is its purpose ? On May 31, 5:19 pm, pbreit wrote: > Which .hgignore? The main distro includes: > applications/*/uploads/* > > http://code.google.com/p/web2py/source/browse/.hgignore#45
[web2py] Re: Versioning bug with wsgi
Sorry for the delay, yes it works. On May 27, 4:24 pm, Massimo Di Pierro wrote: > In wsgihandler if you add: > > sys.stdout=sys.stderr > > does it solve the problem? If so I will add this to trunk. > > On May 27, 9:04 am, "Joseph.Piron" wrote: > > > > > > > > > Hi all, > > > a little annoying bug I encountered a minute ago: > > > I tried the commit in mercurial versioning for an application running > > apache+wgsi_mod, and I got a ticket and this error embedded: > > > IOError: sys.stdout access restricted by mod_wsgi: sys.stdout access > > restricted by mod_wsgi > > > A quick check in the documentation explains: > > > IOError: sys.stdout access restricted by mod_wsgi > > This is because portable WSGI applications should not write to > > sys.stdout or use the 'print' statement without specifying an > > alternate file object besides sys.stdout as the target. This > > restriction can be disabled for the whole server using the > > WSGIRestrictStdout directive, or by mapping sys.stdout to sys.stderr > > at global scope within in the WSGI application script file. > > > Should not this issue be handled ?
[web2py] versioning and uploads
Hi all, I wonder if the uploads directory shouldn't be added in the .hgignore file by the versioning command live databases, cache and so on. What do you think ?
[web2py] Versioning bug with wsgi
Hi all, a little annoying bug I encountered a minute ago: I tried the commit in mercurial versioning for an application running apache+wgsi_mod, and I got a ticket and this error embedded: IOError: sys.stdout access restricted by mod_wsgi: sys.stdout access restricted by mod_wsgi A quick check in the documentation explains: IOError: sys.stdout access restricted by mod_wsgi This is because portable WSGI applications should not write to sys.stdout or use the 'print' statement without specifying an alternate file object besides sys.stdout as the target. This restriction can be disabled for the whole server using the WSGIRestrictStdout directive, or by mapping sys.stdout to sys.stderr at global scope within in the WSGI application script file. Should not this issue be handled ?
[web2py] Re: domain and download function problem
Ok I'm not alone on this server and someone had created an alias / download in the conf.d apache directory... Life's tough sometimes.. :) On May 26, 3:31 pm, Anthony wrote: > On Wednesday, May 25, 2011 5:24:49 AM UTC-4, Joseph.Piron wrote: > > > routers = dict( > > BASE = dict( > > domains = { > > 'stock': 'stock' > > } > > ) > > ) > > > and now, I can access this application athttp://stock, but... > > Now the link to download the images aren't correct anymore: > > > the link accessed fromhttp://stock/stock: > class="photo"> > > > the link accessed fromhttp://stock: > class="photo"> > > Are you saying the image doesn't appear when src="/download/..."? If so, > what happens if you add default_controller='default' to your BASE router, or > if you specify c='default' in your URL call?
[web2py] Re: domain and download function problem
So I tried adding c='default' in the URL call or default_controller in the BASE router, that does not work. I also tried with host=True in the call, does not either. Now I activated the server logging and I can see it looks for / download/stock etc in another directory ... :s I really don't understand ?? On May 26, 3:31 pm, Anthony wrote: > On Wednesday, May 25, 2011 5:24:49 AM UTC-4, Joseph.Piron wrote: > > > routers = dict( > > BASE = dict( > > domains = { > > 'stock': 'stock' > > } > > ) > > ) > > > and now, I can access this application athttp://stock, but... > > Now the link to download the images aren't correct anymore: > > > the link accessed fromhttp://stock/stock: > class="photo"> > > > the link accessed fromhttp://stock: > class="photo"> > > Are you saying the image doesn't appear when src="/download/..."? If so, > what happens if you add default_controller='default' to your BASE router, or > if you specify c='default' in your URL call?
[web2py] Re: domain and download function problem
So as I am investigating this, I gave the pattern based routing system and now it works. Here's my routes.py: routes_in = ( ('/(?P.*)', '/stock/\g'), ) routes_out = ( ('/stock/(?P.*)', '/\g'), ) with that the generated links for the photos are like when http://stock is accessed, so with the controller.. could it be the problem ? On May 25, 11:24 am, "Joseph.Piron" wrote: > Hi guys, > > i got a strange problem, I have made a simple application picking up > data from a database, including an upload field for small photos. > This works perfectly if hosted in the classic way, for example if my > server name is stock and the application is stock (...), if I > accesshttp://stock/stockit works ! > > Then, as this is not pretty, i added a route: > > routers = dict( > BASE = dict( > domains = { > 'stock': 'stock' > } > ) > ) > > and now, I can access this application athttp://stock, but... > Now the link to download the images aren't correct anymore: > > the link accessed fromhttp://stock/stock: class="photo"> > > the link accessed fromhttp://stock: class="photo"> > > and the view code : > > {{if item.photo:}} src="{{=URL(a='stock',f='download',args=item.photo)}}" class="photo"/>{{pass}} > > > (as you can see, I tried adding the application in the URL > generator..) > > Could someone point me where to look at to make it work ? :) > > Thanks in advance !!
[web2py] Re: domain and download function problem
nobody's got a clue ? :) On May 25, 11:24 am, "Joseph.Piron" wrote: > Hi guys, > > i got a strange problem, I have made a simple application picking up > data from a database, including an upload field for small photos. > This works perfectly if hosted in the classic way, for example if my > server name is stock and the application is stock (...), if I > accesshttp://stock/stockit works ! > > Then, as this is not pretty, i added a route: > > routers = dict( > BASE = dict( > domains = { > 'stock': 'stock' > } > ) > ) > > and now, I can access this application athttp://stock, but... > Now the link to download the images aren't correct anymore: > > the link accessed fromhttp://stock/stock: class="photo"> > > the link accessed fromhttp://stock: class="photo"> > > and the view code : > > {{if item.photo:}} src="{{=URL(a='stock',f='download',args=item.photo)}}" class="photo"/>{{pass}} > > > (as you can see, I tried adding the application in the URL > generator..) > > Could someone point me where to look at to make it work ? :) > > Thanks in advance !!
[web2py] domain and download function problem
Hi guys, i got a strange problem, I have made a simple application picking up data from a database, including an upload field for small photos. This works perfectly if hosted in the classic way, for example if my server name is stock and the application is stock (...), if I access http://stock/stock it works ! Then, as this is not pretty, i added a route: routers = dict( BASE = dict( domains = { 'stock': 'stock' } ) ) and now, I can access this application at http://stock , but... Now the link to download the images aren't correct anymore: the link accessed from http://stock/stock : the link accessed from http://stock : and the view code : {{if item.photo:}}{{pass}} (as you can see, I tried adding the application in the URL generator..) Could someone point me where to look at to make it work ? :) Thanks in advance !!
[web2py] Re: Logging of user actions
Ah nice trick also, didn't think about the cache, but where do you put the code to defie the _init_log ? On May 19, 11:23 pm, pbreit wrote: > I got this from here awhile back: > > def _init_log(): > import os,logging,logging.handlers,time > logger = logging.getLogger(request.application) > logger.setLevel(logging.INFO) > handler = logging.handlers.RotatingFileHandler(os.path.join( > request.folder,'logs','applog.log'),'a',1024*1024,1) > handler.setLevel(logging.INFO) #or DEBUG > handler.setFormatter(logging.Formatter( > '%(asctime)s %(levelname)s %(filename)s %(lineno)d %(funcName)s(): > %(message)s')) > logger.addHandler(handler) > return logger > > app_logging = cache.ram('app_wide_log',lambda:_init_log(),time_expire=None) > > Then you can do this from anywhere: > app_logging.info(log_this_data)
[web2py] Re: Logging of user actions
Oh, the auth.log_event I didn't know.. maybe interesting, but i don't want to log in the db, I need to use my logger config. But I can't possibly believe it's rare to log what users do.. Imagine, I have a db of specifications, I want to know who modified which field at what time.. What should be the best way to track this except log it ? Anyway, thanks for the answer :) On May 19, 1:23 am, pbreit wrote: > Not sure exactly what you need but, yes, I think it's kind of rare. > > Maybe this will work for you: by default, Web2py creates an auth_event table > and automatically records a bunch of actions like register, login, etc. > > You can add your own actions with this one-liner: > auth.log_event(description='this happened', origin='auth') > > Both description and origin can be anything I believe.
[web2py] Re: Logging of user actions
Has noone ever had this king of need ?? On May 17, 11:59 pm, "Joseph.Piron" wrote: > Hi all, > > I was wondering what would be the best way to log actions with the > username of the logger user. > I found several leads but none very conclusive. > > For example, define a filter in my model: > > import logging > class ContextFilter(logging.Filter): > def filter(self, record): > record.user = auth.user.username if hasattr(auth.user, > 'username') else "" > return True > > logger = logging.getLogger("web2py.app." + > request.application.lower()) > if len(logger.filters) == 0: > logger.addFilter(ContextFilter()) > > but two issues: auth.user = None in runtime when the context is the > filter method (tried with eclipse debugger) > and moreover, would it work, I would have to define new handlers to > get a new formatter using this new attribute.. not very handy. > > What could be the best option here ? > > Thanks in advance for your advices!
[web2py] Logging of user actions
Hi all, I was wondering what would be the best way to log actions with the username of the logger user. I found several leads but none very conclusive. For example, define a filter in my model: import logging class ContextFilter(logging.Filter): def filter(self, record): record.user = auth.user.username if hasattr(auth.user, 'username') else "" return True logger = logging.getLogger("web2py.app." + request.application.lower()) if len(logger.filters) == 0: logger.addFilter(ContextFilter()) but two issues: auth.user = None in runtime when the context is the filter method (tried with eclipse debugger) and moreover, would it work, I would have to define new handlers to get a new formatter using this new attribute.. not very handy. What could be the best option here ? Thanks in advance for your advices!
[web2py] Re: little bug ldap_auth
Yes it works (MS2003 AD server). On May 17, 3:54 pm, Massimo Di Pierro wrote: > It is possible that some system are more picky than others > does it work if you replace (in line 10) > > '(objectClass=*)' > > with > > 'objectClass=*' > > If it does, it should be changed. > > On May 17, 6:51 am, José Luis Redrejo wrote: > > > > > > > > > 2011/5/17 Joseph.Piron : > > > > Hi all, > > > > I think there's a little bug in ldap_auth.py, indeed for the parameter > > > filterstr of ldap_auth(..) (line 10), the default value is set to > > > (objectClass=*) and during the call of search_ext_s (line 97), the > > > filter argument is constructed with > > > "(&(sAMAccountName=%s)(%s))" % (username_bare, filterstr) > > > > which will introduce double parenthesis around objectClass=* . > > > I suggest to remove them from the default parameter value. > > > Sorry, but I don't see the bug, and it's working perfectly in my systems > > > > Regards all!
[web2py] little bug ldap_auth
Hi all, I think there's a little bug in ldap_auth.py, indeed for the parameter filterstr of ldap_auth(..) (line 10), the default value is set to (objectClass=*) and during the call of search_ext_s (line 97), the filter argument is constructed with "(&(sAMAccountName=%s)(%s))" % (username_bare, filterstr) which will introduce double parenthesis around objectClass=* . I suggest to remove them from the default parameter value. Regards all!
[web2py] Re: SOLVED
Oups wrong place, it goes with http://groups.google.com/group/web2py/browse_thread/thread/e7bc06a9efeb76e4 On Feb 23, 11:33 am, "Joseph.Piron" wrote: > Indeed, it's really.. something. > > Let's explain with an example: > If I have an application called Alfred (mind the 'A'), and I put > 'alfred' or 'aLfred' or else in the browser, the breakpoints are > omitted, but if I use the right casing 'Alfred', breakpoints work! > > Good to know! > But I wonder why :)
[web2py] SOLVED
Indeed, it's really.. something. Let's explain with an example: If I have an application called Alfred (mind the 'A'), and I put 'alfred' or 'aLfred' or else in the browser, the breakpoints are omitted, but if I use the right casing 'Alfred', breakpoints work! Good to know! But I wonder why :)
[web2py] HTTP_RANGE support for streaming to iDevices
Hi all, I was trying to create a plugin for VideoJS html 5 player for web2py. Everything was nice with the demo video from VideoJS server when I tried with my own. It works with Chrome, IE, Safari, Firefox and ... doesn't with iPhone.. (nor FlowPlayer flash player) After some research, it appears it's because iDevices need the support of HTTP_RANGE header in server. It is possible to add it to Rocket, or is it already present ? Here's the chunk of code to download files that I use: def download(): import os, gluon.contenttype if request.args[0].endswith('.avi'): response.headers['Content-Type'] = gluon.contenttype.contenttype('.mp4') elif request.args[0].endswith('.jpg'): response.headers['Content-Type'] = gluon.contenttype.contenttype('.jpg') #response.headers['Content-Disposition'] = request.args[0] return response.stream(open(os.path.join(config.get('mediaDir'), request.args[0])), 4096) Thanks for your help !!!
[web2py] Debug somtimes works, sometimes doesn't..
Hi all, I have a weird issue here.. I'm working with eclipse and pydev and I have defined a project with the full web2py folder. The problem is I can debug several applications such as the welcome or example app, or even the code in web2py.py, but my own apps (created with fast new app options in web interface) can't be debugged anymore. I mean, the debugger doesn't stop at breakpoints. Has anyone already experienced the same ?
[web2py] Re: Unicity condition and database update
Yes I understand that :) And it asks also for triggerValue if not given, but it's a bit annoying. Isn't it possible for it to get those existing values directly ? Thanks. On Feb 3, 7:38 pm, Massimo Di Pierro wrote: > The problem is that unicity must be computed but it needs triggename. > You are not passing triggername when you do the update_rector and > web2y does not do what to do. web2py wants you to be explicit: > > row=db.alarms(2) > row.update_record(message='rz',triggerName=row.triggerName) > > On Feb 3, 4:40 am, "Joseph.Piron" wrote: > > > > > Hi guys, I'm currently facing a strange thing :) > > > I make use of datatables (jquery datatables.net) and jeditable to > > update values in my db. If the user clicks on a value, he changes it > > and sends it, thus, only the value of this field. > > > On the server part, i then do a > > db.alarms[request.vars.id].update_record(field=value). > > > Unfortunately, i have to have a unicity condition for this table, and > > thus, with the previous statement, i get an error. > > > Here's some code to help understand.. > > > db.define_table('alarms', > > Field('triggerName', type = 'string', label = T('Trigger Name'), > > required = True, notnull = True), > > Field('triggerValue', type = 'integer', label = T('Trigger > > Value'), required = True, notnull = True), > > Field('message', type = 'string', label = T('Message'), required = > > True, notnull = True), > > Field('alarmScope', type = 'string', label = T('Alarm Scope'), > > required = True, notnull = True), > > Field('unicity', type = 'string', compute = lambda x: > > x.triggerName + str(x.triggerValue), unique = True), > > format = '%(triggerName)s - %(triggerValue)s', > > migrate = settings.migrate) > > > db.alarms.triggerValue.requires = > > IS_NOT_IN_DB(db(db.alarms.triggerName == request.vars.triggerName), > > 'alarms.triggerValue') > > > If i want to update one of the fields, I have absolutely to also > > update (even if the don't change) triggerName and triggerValue (fields > > for unicity condition), and thus I need some test dependent on which > > field is updated.. > > > Here's an exemple: > > > In [15]: db.alarms[2].update_record(message='rz') > > --- > > KeyError Traceback (most recent call > > last) > > > /Users/joseph/Documents/workspace/web2py/ in > > () > > > /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in (_, > > **a) > > 1245 if field_type == 'id': > > 1246 id = colset[field.name] > > -> 1247 colset.update_record = lambda _ = (colset, > > table, id), **a: update_record(_, a) > > 1248 colset.delete_record = lambda t = table, i > > = id: t._db(t._id==i).delete() > > 1249 for (referee_table, referee_name) in \ > > > /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in > > update_record(pack, a) > > 4433 c = dict([(k,v) for (k,v) in b.items() \ > > 4434 if k in table.fields and not k=='id']) > > -> 4435 table._db(table._id==id).update(**c) > > 4436 for (k, v) in c.items(): > > 4437 colset[k] = v > > > /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update(self, > > **update_fields) > > 4392 def update(self, **update_fields): > > 4393 tablename = self.db._adapter.get_table(self.query) > > -> 4394 fields = > > self.db[tablename]._listify(update_fields,update=True) > > 4395 self.delete_uploaded_files(update_fields) > > 4396 return > > self.db._adapter.update(tablename,self.query,fields) > > > /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in > > _listify(self, fields, update) > > 3748 new_fields.append((ofield,ofield.update)) > > 3749 elif ofield.compute: > > -> 3750 > > new_fields.append((ofield,ofield.compute(Row(fields > > 3751 elif not update and ofield.required: > > 3752 raise SyntaxError,'Table: missing required > > field: %s' % name > > > /Users/joseph/Documents/workspace/web2py/appli
[web2py] Unicity condition and database update
Hi guys, I'm currently facing a strange thing :) I make use of datatables (jquery datatables.net) and jeditable to update values in my db. If the user clicks on a value, he changes it and sends it, thus, only the value of this field. On the server part, i then do a db.alarms[request.vars.id].update_record(field=value). Unfortunately, i have to have a unicity condition for this table, and thus, with the previous statement, i get an error. Here's some code to help understand.. db.define_table('alarms', Field('triggerName', type = 'string', label = T('Trigger Name'), required = True, notnull = True), Field('triggerValue', type = 'integer', label = T('Trigger Value'), required = True, notnull = True), Field('message', type = 'string', label = T('Message'), required = True, notnull = True), Field('alarmScope', type = 'string', label = T('Alarm Scope'), required = True, notnull = True), Field('unicity', type = 'string', compute = lambda x: x.triggerName + str(x.triggerValue), unique = True), format = '%(triggerName)s - %(triggerValue)s', migrate = settings.migrate) db.alarms.triggerValue.requires = IS_NOT_IN_DB(db(db.alarms.triggerName == request.vars.triggerName), 'alarms.triggerValue') If i want to update one of the fields, I have absolutely to also update (even if the don't change) triggerName and triggerValue (fields for unicity condition), and thus I need some test dependent on which field is updated.. Here's an exemple: In [15]: db.alarms[2].update_record(message='rz') --- KeyError Traceback (most recent call last) /Users/joseph/Documents/workspace/web2py/ in () /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in (_, **a) 1245 if field_type == 'id': 1246 id = colset[field.name] -> 1247 colset.update_record = lambda _ = (colset, table, id), **a: update_record(_, a) 1248 colset.delete_record = lambda t = table, i = id: t._db(t._id==i).delete() 1249 for (referee_table, referee_name) in \ /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update_record(pack, a) 4433 c = dict([(k,v) for (k,v) in b.items() \ 4434 if k in table.fields and not k=='id']) -> 4435 table._db(table._id==id).update(**c) 4436 for (k, v) in c.items(): 4437 colset[k] = v /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in update(self, **update_fields) 4392 def update(self, **update_fields): 4393 tablename = self.db._adapter.get_table(self.query) -> 4394 fields = self.db[tablename]._listify(update_fields,update=True) 4395 self.delete_uploaded_files(update_fields) 4396 return self.db._adapter.update(tablename,self.query,fields) /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in _listify(self, fields, update) 3748 new_fields.append((ofield,ofield.update)) 3749 elif ofield.compute: -> 3750 new_fields.append((ofield,ofield.compute(Row(fields 3751 elif not update and ofield.required: 3752 raise SyntaxError,'Table: missing required field: %s' % name /Users/joseph/Documents/workspace/web2py/applications/hmiwebsite/ models/model_alarms.py in (x) 7 Field('message', type = 'string', label = T('Message'), required = True, notnull = True), 8 Field('alarmScope', type = 'string', label = T('Alarm Scope'), required = True, notnull = True), > 9 Field('unicity', type = 'string', compute = lambda x: x.triggerName + str(x.triggerValue), unique = True), 10 format = '%(triggerName)s - %(triggerValue)s', 11 migrate = settings.migrate) /Users/joseph/Documents/workspace/web2py/gluon/dal.pyc in __getattr__(self, key) 3061 3062 def __getattr__(self, key): -> 3063 return dict.__getitem__(self,key) 3064 3065 def __setattr__(self, key, value): KeyError: 'triggerName' Could anyone help me out of this one ? :)