How can I use Plone 4.1.4 to manage autocad drawings with different roles like architect, sr.architect, Project Manager, accounts manager(who manages the user accounts). I would first of all like to know whether Plone can be used to crease a workflow for uploaded autocad drawing files or for uploaded files as such? Doubt arises due to certain plone documentation which say that plone By default, content types Image and File have no workflow.
I wish to track the comments and changes made by the different user roles to the drawing files as well provide a lock i.e iterate through the working copy of the drawing files that have been uploaded. Can anyone suggest the best approach to this project using Plone?
You can change the workflow used for File objects, or indeed copy the File type in portal_types to a a new Drawing type and change the workflow for that new type if you want to treat them differently to standard files in your CMS.
Related
Since I discovered Python, I've created four little applications with Glade + Python + Gtk. For each of them, the structure is a folder, with the name of the app, containing :
an "images" folder
a main .py file which contains all classes that handle all project windows
a .glade file which contains all windows (main app window, about dialog, config dialog, etc.)
a style.css file
(other files as sqlite file and/or json file if neccessary)
Now I'm wondering if this organization is a good practise. Because I've seen a video tutorial in which each window has its own ".ui" file and .py file. Also, other apps seem to be organized like this too and Anjuta projects seem to follow this rule too.
Furthermore, the tutorials that show how to create a Python-Gtk-Glade app are almost all one-window projects...
So my question is : how do you organize your Python-Gtk-Glade projects or what is the best way to do it?
Thanks in advance.
The way you set up your apps will be dictated by your preferences (coding style), the size of the app, and the purpose of the app. However, here are a couple considerations:
Will total lines of Python code be greater than 1000 lines? A file with over a 1000 lines will be unwieldy to navigate. I know code folding, snippets, and etc help but still.
If you have more than one GtkWindow, put each window's .ui and .py separately. This helps when tracking down bugs or adding features. You mentioned sqlite, and sql queries within a file are easier to master 5 years down the road if the files are somewhat purpose specific. If you put dialogs in the same ui file as the parent window, it makes it easier to use set_transient_for and similar programming. Having more than one GtkWindow in a .ui file will make drag and drop widget reordering a pain.
Are parts of the app code reusable? If you find that you are duplicating features in several different files that have different purposes, make a class or function to simplify that one feature (only applicable to multi-file setup).
And finally, when your folder with .ui and .py files starts becoming large (? 25 - 50 files ?) you might want a subfolder that has a group of files with similar functionality. This is not written in stone. Nemo doesn't use this a lot, others do.
I actively develop my own business management software using Python + Gtk found here. I found the principles described above to work well for me.
I think the reason the documentation for Gtk typically shows single file setups is because they are merely proof of concept and not best app management tutorials. App management (for me, anyway) was trial and error, and from studying other open source apps out there.
Disclaimer: These suggestions are my opinion only. They are not endorsed by Python, Gtk, or Glade. You will need to evaluate these suggestions based on your use case.
We have a tool which is designed to allow vendors to deliver files to a company and update their database. These files (generally of predetermined types) use our web-based transport system, a new record is created in the db for each one, and the files are moved into a new structure when delivered.
We have a new request from a client to use this tool to be able to pass through entire directories without parsing every record. Imagine if the client made digital cars then this tool allows the delivery of the digital nuts and bolts and tracks each part, but they want to also deliver a directory with all of the assets which went into creating a digital bolt without adding each asset as a new record.
The issue is that the original code doesn't have a nice way to handle these passthrough folders, and would require a lot of rewriting to make it work. We'd obviously need to create a new function which happens around the time of the directory walk, which takes out each folder which matches this passthrough and then handles it separately. The problem is that all the tools which do the transport, db entry, and delivery all expect files, not folders.
My thinking: what if we could treat that entire folder as a file? That way the current file-level tools don't need to be modified, we'd just need to add the "conversion" step. After generating the manifest, what if we used a library to turn it into a "file", send that, and then turn it back into a "folder" after ingest. The most obvious way to do that is ZIP files - and the current delivery tool does handle ZIPs - but that is slow and some of these deliveries are very large, which means when transporting if something goes wrong the entire ZIP would fail.
Is there a method which we can use which doesn't necessarily compress the files but just somehow otherwise can treat a directory and all its contents like a file, so the rest of the code doesn't need to be rewritten? Or something else I'm missing entirely?
Thanks!
You could use tar files. Python has great support for it, and it is customary in *nix environments to use them as backup files. For compression you could use Gzip (also supported by the standard library and great for streaming).
I have a small python gtk application with embedded webkit. Much like this example code.
The problem is, that my logins (cookies) are not persisted in my application.
I think I need to specify a custom directory, where webkit will save its data (especially cookies). So how to set the directory on my embedded Webkit?
Some time ago I was using gtkmozembed. There I just had to call gtkmozembed.set_profile_path(my_custom_dir, "profile"). Is there something similar for webkit?
I'm looking to store some individual settings to each user's computer. Things like preferences and a license key. From what I know, saving to the registry could be one possibility. However, that won't work on Mac.
One of the easy but not so proper techniques are just saving it to a settings.txt file and reading that on load.
Is there a proper way to save this kind of data? I'm hoping to use my wx app on Windows and Mac.
There is no proper way. Use whatever works best for your particular scenario. Some common ways for storing user data include:
Text files (e.g. Windows INI, cfg files)
binary files (sometimes compressed)
Windows registry
system environment variables
online profiles
There's nothing wrong with using text files. A lot of proper applications uses them exactly for the reason that they are easy to implement, and additionally human readable. The only thing you need to worry about is to make sure you have some form of error handling in place, in case the user decides to replace you config file content with some rubbish.
Take a look at Data Persistence on python docs. One option a you said could be persist them to a simple text file. Or you can save your data using some serialization format as pickle (see previous link) or json but it will be pretty ineficient if you have several keys and values or it will be too complex.
Also, you could save user preferences in an .ini file using python's ConfigParser module as show in this SO answer.
Finally, you can use a database like sqlite3 which is simpler to handle from your code in order to save and retrieve preferences.
I wish to make the contents of a folder in Plone downloadable only for certain roles. Can this be done easily? At present anybody who clicks the hyperlink for file name in the folder contents can download the file easily. I know about the site-wide option of overriding the at_download code using ZMI.
The codeless way to do this is to make use of Plone's workflow system.
Out-of-the-box, Plone's file and image content types do not have their own workflow. That means that files and images will simply inherit the publication state of their parent folder. This is easy and sensible, but it doesn't meet the need you're describing.
To change the situation, you may use the "types" configuration panel to turn on independent workflow for files and images. Then, their publication status may be set separately from their containing folders. Typically, you'd choose the same workflow that you're using for documents. Then, you may publish a folder and list its contents while having the files within be private -- thus requiring login for viewing.
If you need this to work differently in different places, you may turn on "placeful" workflow (turn it on by adding it in the add-ons panel; it's pre-installed, but not active). This allows different workflows in different parts of a site. It increases complexity, but is often an ideal solution to this kind of puzzle.
This is probably not so simple and you need to add some line of code in a little Plone product (no way TTW). Code snippets below are not tested.
Plone file are developed using the Archetypes framework (this will probably change on Plone 5). What you need to change is the read_permission of the file field (see the Archetypes field reference).
from Products.Archetypes.content.file import ATFile
ATFile.schema['file'].read_permission = 'you new permission'
The you simply need to assign your new permission to a role.
This could be not enough (probably step 1 is not useful nowadays). You need to perform the same operation for the [plone.app.blob extension][2]:
from plone.app.blob.subtypes import SchemaExtender
SchemaExtender.fields[0]..read_permission = 'you new permission'
Last one: you probably need to customize the file_view template or an "Unauthorized" error will be raised when a user without the permission will visit the file view.