can I use BytesField in a proto-datasource entity - google-cloud-endpoints

I am trying https://github.com/GoogleCloudPlatform/endpoints-proto-datastore.
I want to save an image related to my entity. Searching revealed that there is indeed a BytesField property type that can be used for this purpose.
I need to know if it is possible to use BytesField in the endpoits-proto-datastore, and if yes how?
Secondly, is this the best way to implement it? or there is a better alternative?
thanks,

Related

tdlib get notifications settings for (another) user

I'm using tdlib and currently trying to create another user's profile screen like this one:
There is usually a field on this screen called "Notifications" containing information on whether or not notifications for given user are muted and if so then for how long. All other fields seem easy to retrieve, but this one is a head-scratcher for me.
All other field are stored in User entity, but what am I supposed to do with this one? Call createPrivateChat only to get one field (namely notificationSettings)? This seems like overkill to me. Isn't there easiest ways to get this? In this issue sapelkinAV states that "chatID is equals UserId". Is it correct? Even if so it might just be an internal thing that we shouldn't rely on, and I can't find neither proofs nor restrictions on abusing this "feature".
If it is fine, than I could use getNotificationSettings and pass notificationSettingsScopeChat as scope parameter. Would it be the right solution? Any thoughts and advices are appreciated!
Official answer (obtained from TDLib bot):
Your usage of createPrivateChat is absolutely correct. To get correct NotificationSettings you need to get information about the corresponding chat.
So I ended up doing exactly that.
Call createPrivateChat only to get one field (namely notificationSettings)?

2sxc: What is the smart way to update an existing app?

just was wondering how could I update an app actually in use, so could not unistall it, so without losing data. Whats the best way? There is an automated feature for this?
Thanks
At the moment there is no automatic feature for this. This is something that can never be fully automated, because an app can be changed in so many ways 2sxc could never automatically figure out how to merge.
I'll try to write a guide some time, but in general there are three quick strategies: if only the views/templates changed, just replace them. If way more changed you could export-import the content-items from "old" to "new" - or you could export/import the schemas from "new" to "old"

Silverstripe: Many to many accessible as a sub url on a Page?

I am struggling with a problem. I've got a sitetree, in which I - obviously - have pages. These pages are of a type that has a many-to-many relationship to a dataobject. Now I would like to achieve something like this:
/Page/DataObject-slug
So, when the system detects that there is an additional "layer" in the url, it should pass that to a predefined function within the Page controller.
Can I use $allowed_actions for that, or would it interfere with the default routings? Also it should be able to use a wildcard, as I don't know the DataObject-slug in advance. If that's not possible, are there any other known ways to achieve this or something similar?
As an alternative, I probably could do something like /Page/SomeAction/DataObject, but that would be really ugly, and probably not acceptable for the customer.
Another option would of course be using controllers as pages, but that would remove the possibility to nest Pages easily for the user, and create a structure like /ParentPage/Page/DataObject-slug.
I am using SS 3.1.6
I successfully used https://github.com/NightJar/ssrigging-slug for this. It shouldn't matter if your relation is a has_many or many_many, you can access the items in your controller with $this->ManyManyRelationName()
It utilizes $url_handlers for this job.
If you have any problems installing it please provide a paste of your code.

Assigning roles in different way

recently i thought to apply roles to users in a different way,without using role manager etc.like create one column named 'ROLES'...and redirect user by checking this column at login time.I know so many of you are thinking what is i am gonna do.I am also thinking the same.I know one drawback of this technique,that is one user cant have multiple roles.Is there any other drawbacks of this technique and why should this technique be avoided and one should use role manager instead of this?
Well Rohan, There is nothing wrong with your way. I have used this type of techniques for 2 years because I was too lazy to go thru the role managers and overriding it where needed.
However i feel now that I have always reinvented the wheel. Its your persective how you see that.
and your last question "why should this technique be avoided and one should use role manager instead of this?" the answer is because it is readymade and timetested. Any new code that you write has a theoritical limit that it can have bug, so suppose you have rolled out your own authentication engine- you will have to test it.. Isnt it extra efford that you have to put?
Use that Link, I think it will help you..

How to prevent access to node based on custom filter/field in node?

I am looking for a way to control access to a node (my own content type), even when it has the "published" bit set. I have a custom field (datetime) that specifies when the node should be available to visitors. How do I hook in to Drupal 7 to do that?
Best regards, Egil.
Have a look on node_access(), you should be able to do what you need there.
I accomplished a similar thing using hook_node_access_records() and hook_node_grants(). My example is for a field within a node that restricts access on a group level, but the same concept works (more easily) for non-group content.
The description of what I did is here: https://drupal.stackexchange.com/questions/36269/how-to-restrict-node-access-to-nodes-based-on-field-value/83975#83975
However, it might be easier for you to follow Node Access Example Module: https://api.drupal.org/api/examples/node_access_example!node_access_example.module/7
That is exactly what I modified to get my code.

Resources