Closed dpinney closed 10 years ago
Related, on my first pass at the user auth I added ?public=true or ?public=false to a bunch of urls to distinguish between public and private objects, but it is really ugly and it wouldn't be too intense to change it to something cleaner, so I will also look into that at some point later.
Hmm. How about debian? That’s our server OS. Honestly we might have to go Windows anyway because Access ODBC connections might be a requirement.
The lack of a creation date is a Unix thing. Apparently, the closest thing to a creation date is the date of the last "metadata" change, whatever that is: https://docs.python.org/2/library/stat.html
And I guess it's not available on debian either: http://stackoverflow.com/questions/14842195/how-to-get-file-creation-date-time-in-bash-debian
I just posted the first link in my comment above as an FYI. os.stat will work on both Windows and Linux, but we just aren't guaranteed a literal creation date with Linux. I'll look into exactly what metadata is, but hopefully it is not something that would change very often.
I still need to test with 10,000 feeders and models, but I have removed pagination, and if you click Model Name/Feeder Name or Date Created it sorts the rows by that. I used underscore.js to update the templates on the front end. Underscore supports JS templates, so I converted metadata.html and feeder.html from flask templates to underscore templates, which was pretty painless - pretty much just exchanging curly braces for angle braces (underscore uses the ERB style template syntax). I didn't remove metadata.html or feeder.html from the source tree, just in case we/I need to reference them still for this redesign.
I'd really prefer to do this without another library...
Why is that?
I've gotta maintain the code and I don't want to learn another library. Wouldn't sorting just require a page reload with a different flag or maybe some javascript to rearrange the table? The server is giving me exceptions when I test it.
I only use the _.template
function from underscore, and I think its use is pretty intuitive. Basically you pass _.template
a template string, and it returns a function. You pass this function the data with which you want to render the template as a JS object, and it returns the rendered template string. You can also pass _.template
the data as the second parameter, and it will return the string rather than a function that can return strings, but I imagine that compiling the template must be more expensive than rendering a pre-compiled template. I will check the source to be sure.
If you want to know more, the documentation for _.template
is only about 1.5 pages long: http://underscorejs.org/#template. I encourage you to at least skim through the entirety of the link I've posted. Underscore is really cool. It turns JavaScript into a much less ugly language, and it doesn't look as weird as jquery, so it would probably be relatively easy to pick up. And all the underscore functions are attributes of a variable that is literally named _
, so if we wanted to use it more heavily, we would know exactly which functions are from underscore and thus where to find documentation that explains them.
I don't really understand what you mean by page reload + rearranging with javascript - wouldn't the point of the page reload be to sort on the backend and then re-render the template with the newly sorted data? That is, what is the role of JS in your suggested implementation? And what do you mean by a different flag?
I really honestly think this is a better way to do it. I think updating the page without completely refreshing it is a more web 2.0, modern way to do it. And the way I do it now is inherently much faster than re-rendering the page. I'm just sending json from the server when a new sort is required, which is a lot less data to send than a template that could very well be thousands of lines of html.
Was the exception TypeError: comparison function must return int, not float
? For some reason I wasn't getting that error when I first pushed it, but all it means is that the comparison function I used to sort by ctime
wasn't returning an integer, which was just a matter of passing the result to int(...)
before actually returning it.
Exception fixed.
When you're finished with web.py we should clean up all the obsolete code and discuss library strategy. You make some good points and the code's already done.
Done.